Commit 6e73850b01ee support to set wwn for disks, but it was not exposed to attach-disk. --- tools/virsh-domain.c | 14 +++++++++++++- tools/virsh.pod | 8 ++++---- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 9ea5ffc..767e288 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -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"); diff --git a/tools/virsh.pod b/tools/virsh.pod index 047c241..69c290f 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -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. -- 1.8.1.4 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list