From 232240d0958fa967cee88d688b48e1bc1c0e1008 Mon Sep 17 00:00:00 2001 From: Osier Yang Date: Tue, 4 Jun 2013 11:27:04 +0800 Subject: [PATCH] virsh: Allow attach-disk to specify disk wwn 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 9ea5ffc97e..767e288a07 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, "%s\n", serial); + if (wwn) + virBufferAsprintf(&buf, " %s\n", wwn); + if (vshCommandOptBool(cmd, "shareable")) virBufferAddLit(&buf, " \n"); diff --git a/tools/virsh.pod b/tools/virsh.pod index 047c241fd3..69c290f2e5 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 is path for the files and devices. I controls the bus or @@ -1870,8 +1870,8 @@ I can specify the two specific mode I or I. I can indicate the type of source (block|file) I can be one of "default", "none", "writethrough", "writeback", "directsync" or "unsafe". -I is the serial of disk device. I indicates the disk device -is shareable between domains. +I is the serial of disk device. I is the wwn of disk device. +I indicates the disk device is shareable between domains. I indicates the disk needs rawio capability. I
is the address of disk device in the form of pci:domain.bus.slot.function, scsi:controller.bus.unit or ide:controller.bus.unit.