]> xenbits.xensource.com Git - libvirt.git/commitdiff
virsh: Allow attach-disk to specify disk wwn
authorOsier Yang <jyang@redhat.com>
Tue, 4 Jun 2013 03:27:04 +0000 (11:27 +0800)
committerOsier Yang <jyang@redhat.com>
Tue, 4 Jun 2013 11:56:07 +0000 (19:56 +0800)
Commit 6e73850b01ee support to set wwn for disks, but it was not
exposed to attach-disk.

tools/virsh-domain.c
tools/virsh.pod

index 9ea5ffc97ecb61eee5a1ca035fb971c3b5ac7bee..767e288a0776f67fa8cf0ce8d2d3217ed3345dfb 100644 (file)
@@ -307,6 +307,10 @@ static const vshCmdOptDef opts_attach_disk[] = {
      .type = VSH_OT_STRING,
      .help = N_("serial of disk device")
     },
+    {.name = "wwn",
+     .type = VSH_OT_STRING,
+     .help = N_("wwn of disk device")
+    },
     {.name = "shareable",
      .type = VSH_OT_BOOL,
      .help = N_("shareable between domains")
@@ -499,7 +503,8 @@ 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, *serial = NULL, *straddr = NULL;
+                *cache = NULL, *serial = NULL, *straddr = NULL,
+                *wwn = NULL;
     struct DiskAddress diskAddr;
     bool isFile = false, functionReturn = false;
     int ret;
@@ -538,6 +543,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
         vshCommandOptStringReq(ctl, cmd, "mode", &mode) < 0 ||
         vshCommandOptStringReq(ctl, cmd, "cache", &cache) < 0 ||
         vshCommandOptStringReq(ctl, cmd, "serial", &serial) < 0 ||
+        vshCommandOptStringReq(ctl, cmd, "wwn", &wwn) < 0 ||
         vshCommandOptStringReq(ctl, cmd, "address", &straddr) < 0 ||
         vshCommandOptStringReq(ctl, cmd, "sourcetype", &stype) < 0)
         goto cleanup;
@@ -564,6 +570,9 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
         }
     }
 
+    if (wwn && !virValidateWWN(wwn))
+        goto cleanup;
+
     /* Make XML of disk */
     virBufferAsprintf(&buf, "<disk type='%s'",
                       (isFile) ? "file" : "block");
@@ -597,6 +606,9 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
     if (serial)
         virBufferAsprintf(&buf, "  <serial>%s</serial>\n", serial);
 
+    if (wwn)
+        virBufferAsprintf(&buf, "  <wwn>%s</wwn>\n", wwn);
+
     if (vshCommandOptBool(cmd, "shareable"))
         virBufferAddLit(&buf, "  <shareable/>\n");
 
index 047c241fd35df13186ea3eb338b84eac8336347b..69c290f2e57e94f0aa11ae61ea2c58ec796ba2a0 100644 (file)
@@ -1849,8 +1849,8 @@ expected.
 [[[I<--live>] [I<--config>] | [I<--current>]] | [I<--persistent>]]
 [I<--driver driver>] [I<--subdriver subdriver>] [I<--cache cache>]
 [I<--type type>] [I<--mode mode>] [I<--config>] [I<--sourcetype soucetype>]
-[I<--serial serial>] [I<--shareable>] [I<--rawio>] [I<--address address>]
-[I<--multifunction>] [I<--print-xml>]
+[I<--serial serial>] [I<--wwn wwn>] [I<--shareable>] [I<--rawio>]
+[I<--address address>] [I<--multifunction>] [I<--print-xml>]
 
 Attach a new disk device to the domain.
 I<source> is path for the files and devices. I<target> controls the bus or
@@ -1870,8 +1870,8 @@ I<mode> can specify the two specific mode I<readonly> or I<shareable>.
 I<sourcetype> can indicate the type of source (block|file)
 I<cache> can be one of "default", "none", "writethrough", "writeback",
 "directsync" or "unsafe".
-I<serial> is the serial of disk device. I<shareable> indicates the disk device
-is shareable between domains.
+I<serial> is the serial of disk device. I<wwn> is the wwn of disk device.
+I<shareable> indicates the disk device is shareable between domains.
 I<rawio> indicates the disk needs rawio capability.
 I<address> is the address of disk device in the form of pci:domain.bus.slot.function,
 scsi:controller.bus.unit or ide:controller.bus.unit.