mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 05:35:25 +00:00
virsh: add --io when attaching disks to guests
virt-install and virt-manager both default to explicitly setting "io='native'" in the disk "driver" tag. virsh, however, does not and also does not provide an option to specify that setting at all. As a result, disks use a different IO mechanism (the default, "threads") when attached post-setup using virsh. Adding this option allows users to keep disk performance consistent for disks attached at install, and those attached afterward.
This commit is contained in:
parent
ed61e0b368
commit
ca21d75d25
@ -267,6 +267,10 @@ static const vshCmdOptDef opts_attach_disk[] = {
|
|||||||
.type = VSH_OT_STRING,
|
.type = VSH_OT_STRING,
|
||||||
.help = N_("cache mode of disk device")
|
.help = N_("cache mode of disk device")
|
||||||
},
|
},
|
||||||
|
{.name = "io",
|
||||||
|
.type = VSH_OT_STRING,
|
||||||
|
.help = N_("io policy of disk device")
|
||||||
|
},
|
||||||
{.name = "type",
|
{.name = "type",
|
||||||
.type = VSH_OT_STRING,
|
.type = VSH_OT_STRING,
|
||||||
.help = N_("target device type")
|
.help = N_("target device type")
|
||||||
@ -504,8 +508,9 @@ 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,
|
||||||
*iothread = NULL, *cache = NULL, *serial = NULL,
|
*iothread = NULL, *cache = NULL, *io = NULL,
|
||||||
*straddr = NULL, *wwn = NULL, *targetbus = NULL;
|
*serial = 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;
|
||||||
@ -537,6 +542,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
|
|||||||
vshCommandOptStringReq(ctl, cmd, "mode", &mode) < 0 ||
|
vshCommandOptStringReq(ctl, cmd, "mode", &mode) < 0 ||
|
||||||
vshCommandOptStringReq(ctl, cmd, "iothread", &iothread) < 0 ||
|
vshCommandOptStringReq(ctl, cmd, "iothread", &iothread) < 0 ||
|
||||||
vshCommandOptStringReq(ctl, cmd, "cache", &cache) < 0 ||
|
vshCommandOptStringReq(ctl, cmd, "cache", &cache) < 0 ||
|
||||||
|
vshCommandOptStringReq(ctl, cmd, "io", &io) < 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 ||
|
||||||
vshCommandOptStringReq(ctl, cmd, "address", &straddr) < 0 ||
|
vshCommandOptStringReq(ctl, cmd, "address", &straddr) < 0 ||
|
||||||
@ -579,7 +585,7 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
|
|||||||
virBufferAddLit(&buf, ">\n");
|
virBufferAddLit(&buf, ">\n");
|
||||||
virBufferAdjustIndent(&buf, 2);
|
virBufferAdjustIndent(&buf, 2);
|
||||||
|
|
||||||
if (driver || subdriver || iothread || cache) {
|
if (driver || subdriver || iothread || cache || io) {
|
||||||
virBufferAddLit(&buf, "<driver");
|
virBufferAddLit(&buf, "<driver");
|
||||||
|
|
||||||
if (driver)
|
if (driver)
|
||||||
@ -590,6 +596,8 @@ cmdAttachDisk(vshControl *ctl, const vshCmd *cmd)
|
|||||||
virBufferAsprintf(&buf, " iothread='%s'", iothread);
|
virBufferAsprintf(&buf, " iothread='%s'", iothread);
|
||||||
if (cache)
|
if (cache)
|
||||||
virBufferAsprintf(&buf, " cache='%s'", cache);
|
virBufferAsprintf(&buf, " cache='%s'", cache);
|
||||||
|
if (io)
|
||||||
|
virBufferAsprintf(&buf, " io='%s'", io);
|
||||||
|
|
||||||
virBufferAddLit(&buf, "/>\n");
|
virBufferAddLit(&buf, "/>\n");
|
||||||
}
|
}
|
||||||
|
@ -2838,7 +2838,7 @@ 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<--iothread iothread>]
|
driver>] [I<--subdriver subdriver>] [I<--iothread iothread>]
|
||||||
[I<--cache cache>] [I<--type type>]
|
[I<--cache cache>] [I<--io io>] [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>]
|
||||||
|
|
||||||
@ -2865,6 +2865,7 @@ 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<io> controls specific policies on I/O; QEMU guests support "threads" and "native".
|
||||||
I<iothread> is the number within the range of domain IOThreads to which
|
I<iothread> is the number within the range of domain IOThreads to which
|
||||||
this disk may be attached (QEMU only).
|
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.
|
||||||
|
Loading…
Reference in New Issue
Block a user