virsh: Add iothread to 'attach-disk'

Add an iothread parameter to allow attaching to an IOThread, such as:

virsh attach-disk $dom $source $target --live --config --iothread 2 \
     --targetbus virtio --driver qemu --subdriver raw  --type disk
This commit is contained in:
John Ferlan 2014-09-02 11:20:41 -04:00
parent 7047d05d06
commit bc5a8090af
2 changed files with 14 additions and 4 deletions

View File

@ -311,6 +311,10 @@ static const vshCmdOptDef opts_attach_disk[] = {
.type = VSH_OT_STRING, .type = VSH_OT_STRING,
.help = N_("subdriver of disk device") .help = N_("subdriver of disk device")
}, },
{.name = "iothread",
.type = VSH_OT_STRING,
.help = N_("IOThread to be used by supported device")
},
{.name = "cache", {.name = "cache",
.type = VSH_OT_STRING, .type = VSH_OT_STRING,
.help = N_("cache mode of disk device") .help = N_("cache mode of disk device")
@ -527,8 +531,8 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
virDomainPtr dom = NULL; virDomainPtr dom = NULL;
const char *source = NULL, *target = NULL, *driver = NULL, const char *source = NULL, *target = NULL, *driver = NULL,
*subdriver = NULL, *type = NULL, *mode = NULL, *subdriver = NULL, *type = NULL, *mode = NULL,
*cache = NULL, *serial = NULL, *straddr = NULL, *iothread = NULL, *cache = NULL, *serial = NULL,
*wwn = NULL, *targetbus = NULL; *straddr = NULL, *wwn = NULL, *targetbus = NULL;
struct DiskAddress diskAddr; struct DiskAddress diskAddr;
bool isFile = false, functionReturn = false; bool isFile = false, functionReturn = false;
int ret; int ret;
@ -558,6 +562,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
vshCommandOptStringReq(ctl, cmd, "subdriver", &subdriver) < 0 || vshCommandOptStringReq(ctl, cmd, "subdriver", &subdriver) < 0 ||
vshCommandOptStringReq(ctl, cmd, "type", &type) < 0 || vshCommandOptStringReq(ctl, cmd, "type", &type) < 0 ||
vshCommandOptStringReq(ctl, cmd, "mode", &mode) < 0 || vshCommandOptStringReq(ctl, cmd, "mode", &mode) < 0 ||
vshCommandOptStringReq(ctl, cmd, "iothread", &iothread) < 0 ||
vshCommandOptStringReq(ctl, cmd, "cache", &cache) < 0 || vshCommandOptStringReq(ctl, cmd, "cache", &cache) < 0 ||
vshCommandOptStringReq(ctl, cmd, "serial", &serial) < 0 || vshCommandOptStringReq(ctl, cmd, "serial", &serial) < 0 ||
vshCommandOptStringReq(ctl, cmd, "wwn", &wwn) < 0 || vshCommandOptStringReq(ctl, cmd, "wwn", &wwn) < 0 ||
@ -601,13 +606,15 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
virBufferAddLit(&buf, ">\n"); virBufferAddLit(&buf, ">\n");
virBufferAdjustIndent(&buf, 2); virBufferAdjustIndent(&buf, 2);
if (driver || subdriver || cache) { if (driver || subdriver || iothread || cache) {
virBufferAddLit(&buf, "<driver"); virBufferAddLit(&buf, "<driver");
if (driver) if (driver)
virBufferAsprintf(&buf, " name='%s'", driver); virBufferAsprintf(&buf, " name='%s'", driver);
if (subdriver) if (subdriver)
virBufferAsprintf(&buf, " type='%s'", subdriver); virBufferAsprintf(&buf, " type='%s'", subdriver);
if (iothread)
virBufferAsprintf(&buf, " iothread='%s'", iothread);
if (cache) if (cache)
virBufferAsprintf(&buf, " cache='%s'", cache); virBufferAsprintf(&buf, " cache='%s'", cache);

View File

@ -2240,7 +2240,8 @@ expected.
=item B<attach-disk> I<domain> I<source> I<target> [[[I<--live>] [I<--config>] =item B<attach-disk> I<domain> I<source> I<target> [[[I<--live>] [I<--config>]
| [I<--current>]] | [I<--persistent>]] [I<--targetbus bus>] [I<--driver | [I<--current>]] | [I<--persistent>]] [I<--targetbus bus>] [I<--driver
driver>] [I<--subdriver subdriver>] [I<--cache cache>] [I<--type type>] driver>] [I<--subdriver subdriver>] [I<--iothread iothread>]
[I<--cache cache>] [I<--type type>]
[I<--mode mode>] [I<--sourcetype sourcetype>] [I<--serial serial>] [I<--wwn [I<--mode mode>] [I<--sourcetype sourcetype>] [I<--serial serial>] [I<--wwn
wwn>] [I<--rawio>] [I<--address address>] [I<--multifunction>] [I<--print-xml>] wwn>] [I<--rawio>] [I<--address address>] [I<--multifunction>] [I<--print-xml>]
@ -2267,6 +2268,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<sourcetype> can indicate the type of source (block|file)
I<cache> can be one of "default", "none", "writethrough", "writeback", I<cache> can be one of "default", "none", "writethrough", "writeback",
"directsync" or "unsafe". "directsync" or "unsafe".
I<iothread> is the number within the range of domain IOThreads to which
this disk may be attached (QEMU only).
I<serial> is the serial of disk device. I<wwn> is the wwn of disk device. I<serial> is the serial of disk device. I<wwn> is the wwn of disk device.
I<rawio> indicates the disk needs rawio capability. 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, I<address> is the address of disk device in the form of pci:domain.bus.slot.function,