diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2012-10-03 10:50:51 +0100 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-10-08 20:04:47 +0100 |
commit | 7786d56db8c22413949f98ef6b15fe0ea367d195 (patch) | |
tree | 7234b2d5b450a21677a9cc19e0b1c506546fa1ee /src/launch-appliance.c | |
parent | 3ad44c866042919374e2d840502e53da2ed8aef0 (diff) | |
download | libguestfs-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 'src/launch-appliance.c')
-rw-r--r-- | src/launch-appliance.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/launch-appliance.c b/src/launch-appliance.c index 531faefd..378f1211 100644 --- a/src/launch-appliance.c +++ b/src/launch-appliance.c @@ -908,6 +908,8 @@ qemu_drive_param (guestfs_h *g, const struct drive *drv, size_t index) len += strlen (drv->iface); if (drv->format) len += strlen (drv->format); + if (drv->disk_label) + len += strlen (drv->disk_label); r = safe_malloc (g, len); @@ -930,11 +932,13 @@ qemu_drive_param (guestfs_h *g, const struct drive *drv, size_t index) else iface = "virtio"; - snprintf (&r[i], len-i, "%s%s%s%s,id=hd%zu,if=%s", + snprintf (&r[i], len-i, "%s%s%s%s%s%s,id=hd%zu,if=%s", drv->readonly ? ",snapshot=on" : "", drv->use_cache_none ? ",cache=none" : "", drv->format ? ",format=" : "", drv->format ? drv->format : "", + drv->disk_label ? ",serial=" : "", + drv->disk_label ? drv->disk_label : "", index, iface); |