Re: [libvirt] [PATCH] virsh: Expose virDomainMigrateSetMaxSpeed API to virsh

Hi, I checked the libvirt git tree. It seems that this patch has not been applied. I think to use virsh command line to control the migration bandwidth is useful. Thanks. - Hui API virDomainMigrateSetMaxSpeed was introduced since 0.9.0, but no command in virsh yet. --- tools/virsh.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ tools/virsh.pod | 5 +++++ 2 files changed, 51 insertions(+), 0 deletions(-) diff --git a/tools/virsh.c b/tools/virsh.c index d98be1c..ab83ba9 100644 --- a/tools/virsh.c +++ b/tools/virsh.c @@ -4301,6 +4301,50 @@ done: } /* + * "migrate-setspeed" command + */ +static const vshCmdInfo info_migrate_setspeed[] = { + {"help", N_("Set the maximum migration bandwidth")}, + {"desc", N_("Set the maximum migration bandwidth (in Mbps) for a domain " + "which is being migrated to another host.")}, + {NULL, NULL} +}; + +static const vshCmdOptDef opts_migrate_setspeed[] = { + {"domain", VSH_OT_DATA, VSH_OFLAG_REQ, N_("domain name, id or uuid")}, + {"bandwidth", VSH_OT_INT, VSH_OFLAG_REQ, N_("migration bandwidth limit in Mbps")}, + {NULL, 0, 0, NULL} +}; + +static bool +cmdMigrateSetMaxSpeed(vshControl *ctl, const vshCmd *cmd) +{ + virDomainPtr dom = NULL; + unsigned long bandwidth = 0; + bool ret = false; + + if (!vshConnectionUsability(ctl, ctl->conn)) + return false; + + if (!(dom = vshCommandOptDomain(ctl, cmd, NULL))) + return false; + + if (vshCommandOptUL(cmd, "bandwidth", &bandwidth) < 0) { + vshError(ctl, "%s", _("migrate: Invalid bandwidth")); + goto done; + } + + if (virDomainMigrateSetMaxSpeed(dom, bandwidth, 0) < 0) + goto done; + + ret = true; + +done: + virDomainFree(dom); + return ret; +} + +/* * "net-autostart" command */ static const vshCmdInfo info_network_autostart[] = { @@ -11080,6 +11124,8 @@ static const vshCmdDef domManagementCmds[] = { {"migrate", cmdMigrate, opts_migrate, info_migrate, 0}, {"migrate-setmaxdowntime", cmdMigrateSetMaxDowntime, opts_migrate_setmaxdowntime, info_migrate_setmaxdowntime, 0}, + {"migrate-setspeed", cmdMigrateSetMaxSpeed, + opts_migrate_setspeed, info_migrate_setspeed, 0}, {"reboot", cmdReboot, opts_reboot, info_reboot, 0}, {"restore", cmdRestore, opts_restore, info_restore, 0}, {"resume", cmdResume, opts_resume, info_resume, 0}, diff --git a/tools/virsh.pod b/tools/virsh.pod index 7ed3003..98adc90 100644 --- a/tools/virsh.pod +++ b/tools/virsh.pod @@ -542,6 +542,11 @@ Set maximum tolerable downtime for a domain which is being live-migrated to another host. The I<downtime> is a number of milliseconds the guest is allowed to be down at the end of live migration. +=item B<migrate-setspeed> I<domain-id> I<bandwidth> + +Set the maximum migration bandwidth (in Mbps) for a domain which is being +migrated to another host. + =item B<reboot> I<domain-id> Reboot a domain. This acts just as if the domain had the B<reboot> -- 1.7.4

On 07/15/2011 12:34 PM, Hui Kang wrote:
Hi, I checked the libvirt git tree. It seems that this patch has not been applied. I think to use virsh command line to control the migration bandwidth is useful. Thanks.
- Hui
API virDomainMigrateSetMaxSpeed was introduced since 0.9.0, but no command in virsh yet. --- tools/virsh.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ tools/virsh.pod | 5 +++++ 2 files changed, 51 insertions(+), 0 deletions(-)
Thanks, but this was indeed applied as commit b73f1f8d5, and in the 0.9.3 release. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

My bad. I found that in the 0.9.3 tags. Thanks. - Hui On 7/15/11 2:57 PM, "Eric Blake" <eblake@redhat.com> wrote:
On 07/15/2011 12:34 PM, Hui Kang wrote:
Hi, I checked the libvirt git tree. It seems that this patch has not been applied. I think to use virsh command line to control the migration bandwidth is useful. Thanks.
- Hui
API virDomainMigrateSetMaxSpeed was introduced since 0.9.0, but no command in virsh yet. --- tools/virsh.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ tools/virsh.pod | 5 +++++ 2 files changed, 51 insertions(+), 0 deletions(-)
Thanks, but this was indeed applied as commit b73f1f8d5, and in the 0.9.3 release.
-- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

HI, Eric, I download the libvirt-0.9.3.tar.gz, compile, and install it. Then when I tried the command "virsh migrate-setspeed vm --bandwidth 1000". It gives me the error "error: unknown procedure: 207" Do you have any solution to this? Thanks. - Hui On 7/15/11 2:57 PM, "Eric Blake" <eblake@redhat.com> wrote:
On 07/15/2011 12:34 PM, Hui Kang wrote:
Hi, I checked the libvirt git tree. It seems that this patch has not been applied. I think to use virsh command line to control the migration bandwidth is useful. Thanks.
- Hui
API virDomainMigrateSetMaxSpeed was introduced since 0.9.0, but no command in virsh yet. --- tools/virsh.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ tools/virsh.pod | 5 +++++ 2 files changed, 51 insertions(+), 0 deletions(-)
Thanks, but this was indeed applied as commit b73f1f8d5, and in the 0.9.3 release.
-- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org

On 07/18/2011 11:34 AM, Hui Kang wrote:
HI, Eric, I download the libvirt-0.9.3.tar.gz, compile, and install it. Then when I tried the command "virsh migrate-setspeed vm --bandwidth 1000". It gives me the error "error: unknown procedure: 207" Do you have any solution to this? Thanks.
That means that your libvirtd daemon is too old. Your client virsh knows a new API that is not yet supported by the server. The solution is to upgrade the running libvirtd to 0.9.3, so that it can honor the newer client's requests. -- Eric Blake eblake@redhat.com +1-801-349-2682 Libvirt virtualization library http://libvirt.org
participants (2)
-
Eric Blake
-
Hui Kang