Commit 98b8d269 authored by Daniel P. Berrange's avatar Daniel P. Berrange

Add VIR_MIGRATE_PARAM_MIGRATE_DISKS constant

Add support for string lists in typed parameters to support the
new migrate-disks parameter. Also add example showing its usage
with migrate_to_uri
parent 9899293a
......@@ -3,6 +3,7 @@ Revision history for perl module Sys::Virt
1.2.17 2015-00-00
- Add VIR_FROM_ADMIN constant
- Add VIR_MIGRATE_PARAM_MIGRATE_DISKS constant
1.2.16 2015-06-01
......
......@@ -272,6 +272,40 @@ vir_typed_param_from_hv(HV *newparams, virTypedParameter *params, int nparams)
}
void vir_typed_param_add_string_list_from_hv(HV *newparams,
virTypedParameter **params,
int *nparams,
const char *key)
{
if (!hv_exists(newparams, key, strlen(key))) {
return;
}
SSize_t nstr, i;
virTypedParameter *localparams = *params;
SV **val = hv_fetch(newparams, key, strlen(key), 0);
AV *av = (AV*)(SvRV(*val));
nstr = av_top_index(av) + 1;
Renew(localparams, *nparams + nstr, virTypedParameter);
for (i = 0 ; i < nstr ; i++) {
STRLEN len;
SV **val = av_fetch(av, i, 0);
char *ptr = SvPV(*val, len);
strncpy(localparams[*nparams + i].field, key,
VIR_TYPED_PARAM_FIELD_LENGTH);
localparams[*nparams + i].type = VIR_TYPED_PARAM_STRING;
localparams[*nparams + i].value.s = ptr;
}
*params = localparams;
*nparams += nstr;
}
static int
_domain_event_lifecycle_callback(virConnectPtr con,
virDomainPtr dom,
......@@ -4374,9 +4408,11 @@ _migrate(dom, destcon, newparams, flags=0)
VIR_TYPED_PARAM_FIELD_LENGTH);
params[5].type = VIR_TYPED_PARAM_STRING;
nparams = vir_typed_param_from_hv(newparams, params, nparams);
vir_typed_param_add_string_list_from_hv(newparams, &params, &nparams,
VIR_MIGRATE_PARAM_MIGRATE_DISKS);
/* No need to support virDomainMigrate/virDomainMigrate2, since
* virDomainMigrate3 takes care to call the older APIs internally
* if it is possible todo so
......@@ -4429,6 +4465,9 @@ _migrate_to_uri(dom, desturi, newparams, flags=0)
nparams = vir_typed_param_from_hv(newparams, params, nparams);
vir_typed_param_add_string_list_from_hv(newparams, &params, &nparams,
VIR_MIGRATE_PARAM_MIGRATE_DISKS);
/* No need to support virDomainMigrateToURI/virDomainMigrateToURI2, since
* virDomainMigrate3 takes care to call the older APIs internally
* if it is possible todo so
......@@ -7448,6 +7487,7 @@ BOOT:
REGISTER_CONSTANT_STR(VIR_MIGRATE_PARAM_GRAPHICS_URI, MIGRATE_PARAM_GRAPHICS_URI);
REGISTER_CONSTANT_STR(VIR_MIGRATE_PARAM_URI, MIGRATE_PARAM_URI);
REGISTER_CONSTANT_STR(VIR_MIGRATE_PARAM_LISTEN_ADDRESS, MIGRATE_PARAM_LISTEN_ADDRESS);
REGISTER_CONSTANT_STR(VIR_MIGRATE_PARAM_MIGRATE_DISKS, MIGRATE_PARAM_MIGRATE_DISKS);
REGISTER_CONSTANT(VIR_DOMAIN_XML_SECURE, XML_SECURE);
REGISTER_CONSTANT(VIR_DOMAIN_XML_INACTIVE, XML_INACTIVE);
......
#!/usr/bin/perl
use strict;
use warnings;
use Sys::Virt;
use Sys::Virt::Domain;
if (int(@ARGV) < 4) {
die "syntax: $0 URI DOMAIN DEST-URI DISK1 [DISK2 [DISK3 ...]]";
}
my $uri = shift @ARGV;
my $c = Sys::Virt->new(uri => $uri);
my $dom = $c->get_domain_by_name(shift @ARGV);
my $desturi = shift @ARGV;
my @disks = @ARGV;
$dom->migrate_to_uri(
$desturi, {
Sys::Virt::Domain::MIGRATE_PARAM_MIGRATE_DISKS => \@disks,
},
Sys::Virt::Domain::MIGRATE_PEER2PEER);
......@@ -977,6 +977,13 @@ host, thus use of an explicit restricted listen address is recommended.
=back
=item C<Sys::Virt::Domain::MIGRATE_PARAM_MIGRATE_DISKS>
The list of disks to migrate when doing block storage migration.
In constrast to other parameters whose values are plain strings,
the parameter value should be an array reference, whose elements
are in turn strings representing the disk target names.
=item $ddom = $dom->migrate(destcon, flags=0, dname=undef, uri=undef, bandwidth=0)
Migrate a domain to an alternative host. Use of positional parameters
......
......@@ -118,6 +118,7 @@ virTypedParamsAddFromString
virTypedParamsAddInt
virTypedParamsAddLLong
virTypedParamsAddString
virTypedParamsAddStringList
virTypedParamsAddUInt
virTypedParamsAddULLong
virTypedParamsClear
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment