Re: [libvirt] [PATCH 8/8] virsh: Add support for setting post-copy migration bandwidth
On Tue, Feb 05, 2019 at 04:23:11PM +0100, Jiri Denemark wrote: Signed-off-by: Jiri Denemark --- tools/virsh-domain.c | 33 +++-- tools/virsh.pod | 15 +++ 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 275ac0c318..db0d5d4dcc 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -11150,6 +11163,10 @@ static const vshCmdOptDef opts_migrate_setspeed[] = { .flags = VSH_OFLAG_REQ, .help = N_("migration bandwidth limit in MiB/s") }, +{.name = "postcopy", + .type = VSH_OT_BOOL, + .help = N_("set postcopy migration bandwidth") post-copy +}, {.name = NULL} }; @@ -11191,6 +11212,10 @@ static const vshCmdInfo info_migrate_getspeed[] = { static const vshCmdOptDef opts_migrate_getspeed[] = { VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), +{.name = "postcopy", + .type = VSH_OT_BOOL, + .help = N_("get postcopy migration bandwidth") post-copy +}, {.name = NULL} }; Reviewed-by: Ján Tomko Jano signature.asc Description: PGP signature -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 8/8] virsh: Add support for setting post-copy migration bandwidth
Signed-off-by: Jiri Denemark --- tools/virsh-domain.c | 33 +++-- tools/virsh.pod | 15 +++ 2 files changed, 42 insertions(+), 6 deletions(-) diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 275ac0c318..db0d5d4dcc 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -10557,6 +10557,10 @@ static const vshCmdOptDef opts_migrate[] = { .type = VSH_OT_BOOL, .help = N_("use TLS for migration") }, +{.name = "postcopy-bandwidth", + .type = VSH_OT_INT, + .help = N_("post-copy migration bandwidth limit in MiB/s") +}, {.name = NULL} }; @@ -10753,6 +10757,15 @@ doMigrate(void *opaque) goto save_error; } +if ((rv = vshCommandOptULongLong(ctl, cmd, "postcopy-bandwidth", )) < 0) { +goto out; +} else if (rv > 0) { +if (virTypedParamsAddULLong(, , , +VIR_MIGRATE_PARAM_BANDWIDTH_POSTCOPY, +ullOpt) < 0) +goto save_error; +} + if (vshCommandOptBool(cmd, "live")) flags |= VIR_MIGRATE_LIVE; if (vshCommandOptBool(cmd, "p2p")) @@ -11150,6 +11163,10 @@ static const vshCmdOptDef opts_migrate_setspeed[] = { .flags = VSH_OFLAG_REQ, .help = N_("migration bandwidth limit in MiB/s") }, +{.name = "postcopy", + .type = VSH_OT_BOOL, + .help = N_("set postcopy migration bandwidth") +}, {.name = NULL} }; @@ -11158,6 +11175,7 @@ cmdMigrateSetMaxSpeed(vshControl *ctl, const vshCmd *cmd) { virDomainPtr dom = NULL; unsigned long bandwidth = 0; +unsigned int flags = 0; bool ret = false; if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) @@ -11166,7 +11184,10 @@ cmdMigrateSetMaxSpeed(vshControl *ctl, const vshCmd *cmd) if (vshCommandOptULWrap(ctl, cmd, "bandwidth", ) < 0) goto done; -if (virDomainMigrateSetMaxSpeed(dom, bandwidth, 0) < 0) +if (vshCommandOptBool(cmd, "postcopy")) +flags |= VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY; + +if (virDomainMigrateSetMaxSpeed(dom, bandwidth, flags) < 0) goto done; ret = true; @@ -11191,6 +11212,10 @@ static const vshCmdInfo info_migrate_getspeed[] = { static const vshCmdOptDef opts_migrate_getspeed[] = { VIRSH_COMMON_OPT_DOMAIN_FULL(VIR_CONNECT_LIST_DOMAINS_ACTIVE), +{.name = "postcopy", + .type = VSH_OT_BOOL, + .help = N_("get postcopy migration bandwidth") +}, {.name = NULL} }; @@ -11199,12 +11224,16 @@ cmdMigrateGetMaxSpeed(vshControl *ctl, const vshCmd *cmd) { virDomainPtr dom = NULL; unsigned long bandwidth; +unsigned int flags = 0; bool ret = false; if (!(dom = virshCommandOptDomain(ctl, cmd, NULL))) return false; -if (virDomainMigrateGetMaxSpeed(dom, , 0) < 0) +if (vshCommandOptBool(cmd, "postcopy")) +flags |= VIR_DOMAIN_MIGRATE_MAX_SPEED_POSTCOPY; + +if (virDomainMigrateGetMaxSpeed(dom, , flags) < 0) goto done; vshPrint(ctl, "%lu\n", bandwidth); diff --git a/tools/virsh.pod b/tools/virsh.pod index 59a5900162..67edb57b14 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -1903,6 +1903,7 @@ I I [I] [I] [I] [I] [I<--comp-mt-threads>] [I<--comp-mt-dthreads>] [I<--comp-xbzrle-cache>] [I<--auto-converge>] [I] [I] [I<--persistent-xml> B] [I<--tls>] +[I<--postcopy-bandwidth> B] Migrate domain to another host. Add I<--live> for live migration; <--p2p> for peer-2-peer migration; I<--direct> for direct migration; or I<--tunnelled> @@ -1933,6 +1934,8 @@ Once migration is running, the user may switch to post-copy using the B command sent from another virsh instance or use I<--postcopy-after-precopy> along with I<--postcopy> to let libvirt automatically switch to post-copy after the first pass of pre-copy is finished. +The maximum bandwidth consumed during the post-copy phase may be limited using +I<--postcopy-bandwidth>. I<--auto-converge> forces convergence during live migration. The initial guest CPU throttling rate can be set with I. If the @@ -2098,17 +2101,21 @@ is supposed to be used while the domain is being live-migrated as a reaction to migration progress and increasing number of compression cache misses obtained from domjobinfo. -=item B I I +=item B I I [I<--postcopy>] Set the maximum migration bandwidth (in MiB/s) for a domain which is being migrated to another host. I is interpreted as an unsigned long long value. Specifying a negative value results in an essentially unlimited value being provided to the hypervisor. The hypervisor can choose whether to -reject the value or convert it to the maximum value allowed. +reject the value or convert it to the maximum value allowed. If the +I<--postcopy> option is specified, the command will set the maximum bandwidth +allowed during a post-copy migration phase. -=item B I +=item B I [I<--postcopy>] -Get the maximum migration bandwidth (in
[libvirt] [PATCH 8/8] virsh: Add support for virDomainGetDescription api
This patch modifies the description parser to use the new API if available with option to fall back to XML parsing. --- tools/virsh.c | 20 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index 976c2d9..08bfb27 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -17851,9 +17851,29 @@ vshGetDomainDescription(vshControl *ctl, virDomainPtr dom, bool title, { char *desc = NULL; char *domxml = NULL; +virErrorPtr err = NULL; xmlDocPtr doc = NULL; xmlXPathContextPtr ctxt = NULL; +int apiflags = flags; +if (title) +apiflags |= VIR_DOMAIN_DESCRIPTION_TITLE; + +if ((desc = virDomainGetDescription(dom, apiflags))) { +return desc; +} else { +err = virGetLastError(); + +if (err err-code == VIR_ERR_OPERATION_FAILED) { +desc = vshStrdup(ctl, ); +return desc; +} + +if (err err-code != VIR_ERR_NO_SUPPORT) +return desc; +} + +/* fall back to xml */ /* get domains xml description and extract the title/description */ if (!(domxml = virDomainGetXMLDesc(dom, flags))) { vshError(ctl, %s, _(Failed to retrieve domain XML)); -- 1.7.3.4 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
[libvirt] [PATCH 8/8] virsh: add -- support
-- means no option at the following arguments. Signed-off-by: Lai Jiangshan la...@cn.fujitsu.com --- diff --git a/tools/virsh.c b/tools/virsh.c index a5b438b..d01091f 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -10305,6 +10305,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser) vshCmdOpt *last = NULL; const vshCmdDef *cmd = NULL; int tk; +bool data_only = false; int data_ct = 0; first = NULL; @@ -10327,6 +10328,8 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser) goto syntaxError; /* ... or ignore this command only? */ } VIR_FREE(tkdata); +} else if (data_only) { +goto get_data; } else if (*tkdata == '-' *(tkdata + 1) == '-' *(tkdata + 2) c_isalnum(*(tkdata + 2))) { char *optstr = strchr(tkdata + 2, '='); @@ -10368,7 +10371,12 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser) goto syntaxError; } } +} else if (*tkdata == '-' *(tkdata + 1) == '-' +*(tkdata + 2) == '\0') { +data_only = true; +continue; } else { +get_data: if (!(opt = vshCmddefGetData(cmd, data_ct++))) { vshError(ctl, _(unexpected data '%s'), tkdata); goto syntaxError; -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH 8/8] virsh: add -- support
On 10/12/2010 01:14 AM, Lai Jiangshan wrote: -- means no option at the following arguments. Signed-off-by: Lai Jiangshanla...@cn.fujitsu.com --- diff --git a/tools/virsh.c b/tools/virsh.c index a5b438b..d01091f 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -10305,6 +10305,7 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser) vshCmdOpt *last = NULL; const vshCmdDef *cmd = NULL; int tk; +bool data_only = false; int data_ct = 0; first = NULL; @@ -10327,6 +10328,8 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser) goto syntaxError; /* ... or ignore this command only? */ } VIR_FREE(tkdata); +} else if (data_only) { +goto get_data; } else if (*tkdata == '-' *(tkdata + 1) == '-' *(tkdata + 2) c_isalnum(*(tkdata + 2))) { char *optstr = strchr(tkdata + 2, '='); @@ -10368,7 +10371,12 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser) goto syntaxError; } } +} else if (*tkdata == '-' *(tkdata + 1) == '-' + *(tkdata + 2) == '\0') { Another case of line break convention. Also, I prefer tkdata[1] over *(tkdata + 1). Hmm, that means there's now two levels of -- parsing - one to mark the end of top-level virsh commands, and one for each command. That is: virsh -- help -- help should be the same as virsh help help Which also means that virsh should probably be avoiding argv rearrangement in getopt_long(). That is, given my theoretical echo command, virsh echo --help should echo --help, rather than running 'virsh --help'. Or, more to the point, virsh dumpxml --update-cpu vm correctly avoids promoting --update-cpu to a top-level argument of virsh. Oh my - I just looked in the code, and virsh is re-doing option parsing by itself, instead of just telling getopt_long() to stop on the first non-option; but getting it wrong by not checking for abbreviations. Another patch or two coming up... ACK with the nit fixed. Here's what I'm squashing. diff --git i/tools/virsh.c w/tools/virsh.c index 79d7756..8c4a7bc 100644 --- i/tools/virsh.c +++ w/tools/virsh.c @@ -10347,8 +10347,8 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser) VIR_FREE(tkdata); } else if (data_only) { goto get_data; -} else if (*tkdata == '-' *(tkdata + 1) == '-' *(tkdata + 2) -c_isalnum(*(tkdata + 2))) { +} else if (tkdata[0] == '-' tkdata[1] == '-' + c_isalnum(tkdata[2])) { char *optstr = strchr(tkdata + 2, '='); if (optstr) { *optstr = '\0'; /* convert the '=' to '\0' */ @@ -10388,8 +10388,8 @@ vshCommandParse(vshControl *ctl, vshCommandParser *parser) goto syntaxError; } } -} else if (*tkdata == '-' *(tkdata + 1) == '-' -*(tkdata + 2) == '\0') { +} else if (tkdata[0] == '-' tkdata[1] == '-' + tkdata[2] == '\0') { data_only = true; continue; } else { -- Eric Blake ebl...@redhat.com+1-801-349-2682 Libvirt virtualization library http://libvirt.org -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list