summaryrefslogtreecommitdiffstats
path: root/generator
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-10-03 10:50:51 +0100
committerRichard W.M. Jones <rjones@redhat.com>2012-10-08 20:04:47 +0100
commit7786d56db8c22413949f98ef6b15fe0ea367d195 (patch)
tree7234b2d5b450a21677a9cc19e0b1c506546fa1ee /generator
parent3ad44c866042919374e2d840502e53da2ed8aef0 (diff)
downloadlibguestfs-7786d56db8c22413949f98ef6b15fe0ea367d195.tar.gz
libguestfs-7786d56db8c22413949f98ef6b15fe0ea367d195.tar.xz
libguestfs-7786d56db8c22413949f98ef6b15fe0ea367d195.zip
launch: Add add_drive 'label' option.
New API: list-disk-labels Allow the user to pass an optional disk label when adding a drive. This is passed through to qemu / libvirt using the disk serial field, and from there to the appliance which exposes it through udev, creating a special alias of the device /dev/disk/guestfs/<label>. Partitions are named /dev/disk/guestfs/<label><partnum>. virtio-blk and virtio-scsi limit the serial field to 20 bytes. We further limit the name to maximum 20 ASCII characters in [a-zA-Z]. list-devices and list-partitions are not changed: these calls still return raw block device names. However a new call, list-disk-labels, returns a hash table allowing callers to map between disk labels, and block device and partition names. This commit also includes a test.
Diffstat (limited to 'generator')
-rw-r--r--generator/actions.ml28
1 files changed, 27 insertions, 1 deletions
diff --git a/generator/actions.ml b/generator/actions.ml
index 713c7162..25d28098 100644
--- a/generator/actions.ml
+++ b/generator/actions.ml
@@ -1184,7 +1184,7 @@ not all belong to a single logical operating system
{ defaults with
name = "add_drive";
- style = RErr, [String "filename"], [OBool "readonly"; OString "format"; OString "iface"; OString "name"];
+ style = RErr, [String "filename"], [OBool "readonly"; OString "format"; OString "iface"; OString "name"; OString "label"];
once_had_no_optargs = true;
fish_alias = ["add"]; config_only = true;
shortdesc = "add an image to examine or modify";
@@ -1238,6 +1238,15 @@ The name the drive had in the original guest, e.g. C</dev/sdb>.
This is used as a hint to the guest inspection process if
it is available.
+=item C<label>
+
+Give the disk a label. The label should be a unique, short
+string using I<only> ASCII characters C<[a-zA-Z]>.
+As well as its usual name in the API (such as C</dev/sda>),
+the drive will also be named C</dev/disk/guestfs/I<label>>.
+
+See L<guestfs(3)/DISK LABELS>.
+
=back" };
{ defaults with
@@ -9925,6 +9934,23 @@ on C<device>. The optional C<blockscount> is the size of the
filesystem in blocks. If omitted it defaults to the size of
C<device>." (* XXX document optional args properly *) };
+ { defaults with
+ name = "list_disk_labels";
+ style = RHashtable "labels", [], [];
+ proc_nr = Some 369;
+ tests = [];
+ shortdesc = "mapping of disk labels to devices";
+ longdesc = "\
+If you add drives using the optional C<label> parameter
+of C<guestfs_add_drive_opts>, you can use this call to
+map between disk labels, and raw block device and partition
+names (like C</dev/sda> and C</dev/sda1>).
+
+This returns a hashtable, where keys are the disk labels
+(I<without> the C</dev/disk/guestfs> prefix), and the values
+are the full raw block device and partition names
+(eg. C</dev/sda> and C</dev/sda1>)." };
+
]
(* Non-API meta-commands available only in guestfish.