[PATCH 2/3] Add --serial option for attach-disk

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Add --serial option for attach-disk to allow user to specify serial
string of disk device from virsh command line when attaching a disk
device.
---
 tools/virsh.c   |    7 ++++++-
 tools/virsh.pod |    2 ++
 2 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/tools/virsh.c b/tools/virsh.c
index cab5a35..c30f333 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -10181,6 +10181,7 @@ static const vshCmdOptDef opts_attach_disk[] = {
     {"mode",    VSH_OT_STRING, 0, N_("mode of device reading and writing")},
     {"persistent", VSH_OT_BOOL, 0, N_("persist disk attachment")},
     {"sourcetype", VSH_OT_STRING, 0, N_("type of source (block|file)")},
+    {"serial", VSH_OT_STRING, 0, N_("serial of disk device")},
     {NULL, 0, 0, NULL}
 };
 
@@ -10190,7 +10191,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
     virDomainPtr dom = NULL;
     const char *source = NULL, *target = NULL, *driver = NULL,
                 *subdriver = NULL, *type = NULL, *mode = NULL,
-                *cache = NULL;
+                *cache = NULL, *serial = NULL;
     bool isFile = false, functionReturn = false;
     int ret;
     unsigned int flags;
@@ -10220,6 +10221,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
     }
 
     ignore_value(vshCommandOptString(cmd, "cache", &cache));
+    ignore_value(vshCommandOptString(cmd, "serial", &serial));
 
     if (!stype) {
         if (driver && (STREQ(driver, "file") || STREQ(driver, "tap")))
@@ -10266,6 +10268,9 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
     if (mode)
         virBufferAsprintf(&buf, "  <%s/>\n", mode);
 
+    if (serial)
+        virBufferAsprintf(&buf, "  <serial>%s</serial>\n", serial);
+
     virBufferAddLit(&buf, "</disk>\n");
 
     if (virBufferError(&buf)) {
diff --git a/tools/virsh.pod b/tools/virsh.pod
index 79f49ba..95e7744 100644
--- a/tools/virsh.pod
+++ b/tools/virsh.pod
@@ -876,6 +876,7 @@ the single existing device; consider using B<update-device> for this usage.
 =item B<attach-disk> I<domain-id> I<source> I<target> optional
 I<--driver driver> I<--subdriver subdriver> I<--cache cache>
 I<--type type> I<--mode mode> I<--persistent> I<--sourcetype soucetype>
+I<--serial serial>
 
 Attach a new disk device to the domain.
 I<source> and I<target> are paths for the files and devices.
@@ -887,6 +888,7 @@ I<mode> can specify the two specific mode I<readonly> or I<shareable>.
 I<persistent> indicates the changes will affect the next boot of the domain.
 I<sourcetype> can indicate the type of source (block|file)
 I<cache> can be one of "default", "none", "writethrough" or "writeback".
+I<serial> is the serial of disk device.
 
 =item B<attach-interface> I<domain-id> I<type> I<source> optional
 I<--target target> I<--mac mac> I<--script script> I<--model model>
-- 
1.7.5.1

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]