On 16.06.2015 00:42, Pavel Boldin wrote:
Behold of the fourth re-roll of the selective block device migration
patch.
In this patch we don't only fix the issue with NBD migration format auto-
detection but also introduce the patches that do enhance the NBD migration
triggered by `drive-mirror` QEMU command with ability for the user to select
what disks are to be migrated based on the target name.
First two patches fix some nitpicks, third one fixes the issue with NBD format
auto-detection.
Middle ones introduce a necessary API to keep a list of block devices to
migrate in the virTypedParameter array and to work with this list.
Of the two last patches first introduces the `migrate_disks' qemuMigration*
parameter and pushes it down the call stack making the code to consult it when
there is a decision to be made whether the block device is to be migrated to
the new host. When there is no `migrate_disks' parameter given then the old
scheme is used: only non-shared non-readonly disks with a source are migrated.
The last patch promotes this ability up to the virsh utility and documents
it as appropriate.
Michal Privoznik (3):
virDomainDiskGetSource: Mark passed disk as 'const'
qemuMigrationBeginPhase: Fix function header indentation
qemuMigrationDriveMirror: Force raw format for NBD
Pavel Boldin (6):
util: multi-value virTypedParameter
util: multi-value parameters in virTypedParamsAdd*
util: virTypedParams{Filter,GetAllStrings}
util: add virTypedParamsAddStringList
qemu: migration: selective block device migration
virsh: selective block device migration
include/libvirt/libvirt-domain.h | 9 ++
include/libvirt/libvirt-host.h | 11 ++
src/conf/domain_conf.c | 2 +-
src/conf/domain_conf.h | 2 +-
src/libvirt_public.syms | 6 +
src/qemu/qemu_driver.c | 78 ++++++++---
src/qemu/qemu_migration.c | 264 +++++++++++++++++++++++++----------
src/qemu/qemu_migration.h | 24 ++--
src/util/virtypedparam.c | 259 +++++++++++++++++++++++++++-------
src/util/virtypedparam.h | 19 +++
tests/Makefile.am | 6 +
tests/virtypedparamtest.c | 295 +++++++++++++++++++++++++++++++++++++++
tools/virsh-domain.c | 23 +++
tools/virsh.pod | 21 +--
14 files changed, 854 insertions(+), 165 deletions(-)
create mode 100644 tests/virtypedparamtest.c
Basically, this is the diff of the all nits I've pointed out:
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index f7373af..6c41e89 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -2272,6 +2272,8 @@ virTypedParameterTypeFromString;
virTypedParameterTypeToString;
virTypedParamsCheck;
virTypedParamsCopy;
+virTypedParamsFilter;
+virTypedParamsGetAllStrings;
virTypedParamsReplaceString;
virTypedParamsValidate;
diff --git a/src/libvirt_public.syms b/src/libvirt_public.syms
index ccc7532..59d8c12 100644
--- a/src/libvirt_public.syms
+++ b/src/libvirt_public.syms
@@ -717,7 +717,6 @@ LIBVIRT_1.2.16 {
LIBVIRT_1.3.0 {
global:
- virTypedParamsGetAllStrings;
virTypedParamsAddStringList;
} LIBVIRT_1.2.16;
diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c
index d56579b..4c6b530 100644
--- a/src/qemu/qemu_driver.c
+++ b/src/qemu/qemu_driver.c
@@ -12351,7 +12351,7 @@ qemuDomainMigrateBegin3(virDomainPtr domain,
}
return qemuMigrationBegin(domain->conn, vm, xmlin, dname,
- cookieout, cookieoutlen, flags, 0, NULL);
+ cookieout, cookieoutlen, 0, NULL, flags);
}
static char *
@@ -12381,9 +12381,9 @@ qemuDomainMigrateBegin3Params(virDomainPtr domain,
&dname) < 0)
goto cleanup;
- nmigrate_disks = virTypedParamsGetAllStrings(
- params, nparams, VIR_MIGRATE_PARAM_MIGRATE_DISKS,
- &migrate_disks);
+ nmigrate_disks = virTypedParamsGetAllStrings(params, nparams,
+ VIR_MIGRATE_PARAM_MIGRATE_DISKS,
+ &migrate_disks);
if (nmigrate_disks < 0)
goto cleanup;
@@ -12397,8 +12397,8 @@ qemuDomainMigrateBegin3Params(virDomainPtr domain,
}
ret = qemuMigrationBegin(domain->conn, vm, xmlin, dname,
- cookieout, cookieoutlen, flags,
- nmigrate_disks, migrate_disks);
+ cookieout, cookieoutlen,
+ nmigrate_disks, migrate_disks, flags);
cleanup:
VIR_FREE(migrate_disks);
@@ -12495,9 +12495,9 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn,
&listenAddress) < 0)
goto cleanup;
- nmigrate_disks = virTypedParamsGetAllStrings(
- params, nparams, VIR_MIGRATE_PARAM_MIGRATE_DISKS,
- &migrate_disks);
+ nmigrate_disks = virTypedParamsGetAllStrings(params, nparams,
+ VIR_MIGRATE_PARAM_MIGRATE_DISKS,
+ &migrate_disks);
if (nmigrate_disks < 0)
goto cleanup;
@@ -12688,7 +12688,7 @@ qemuDomainMigratePerform3Params(virDomainPtr dom,
virCheckFlags(QEMU_MIGRATION_FLAGS, -1);
if (virTypedParamsValidate(params, nparams, QEMU_MIGRATION_PARAMETERS) < 0)
- return -1;
+ return ret;
if (virTypedParamsGetString(params, nparams,
VIR_MIGRATE_PARAM_DEST_XML,
@@ -12710,9 +12710,9 @@ qemuDomainMigratePerform3Params(virDomainPtr dom,
&listenAddress) < 0)
goto cleanup;
- nmigrate_disks = virTypedParamsGetAllStrings(
- params, nparams, VIR_MIGRATE_PARAM_MIGRATE_DISKS,
- &migrate_disks);
+ nmigrate_disks = virTypedParamsGetAllStrings(params, nparams,
+ VIR_MIGRATE_PARAM_MIGRATE_DISKS,
+ &migrate_disks);
if (nmigrate_disks < 0)
goto cleanup;
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 275d416..7fae75b 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -1584,6 +1584,7 @@ qemuMigrateDisk(virDomainDiskDef const *disk,
size_t nmigrate_disks, const char **migrate_disks)
{
size_t i;
+
/* Check if the disk alias is in the list */
if (nmigrate_disks) {
for (i = 0; i < nmigrate_disks; i++) {
@@ -2871,9 +2872,9 @@ qemuMigrationBegin(virConnectPtr conn,
const char *dname,
char **cookieout,
int *cookieoutlen,
- unsigned long flags,
size_t nmigrate_disks,
- const char **migrate_disks)
+ const char **migrate_disks,
+ unsigned long flags)
{
virQEMUDriverPtr driver = conn->privateData;
char *xml = NULL;
diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h
index 2a942c0..030b32f 100644
--- a/src/qemu/qemu_migration.h
+++ b/src/qemu/qemu_migration.h
@@ -101,9 +101,9 @@ char *qemuMigrationBegin(virConnectPtr conn,
const char *dname,
char **cookieout,
int *cookieoutlen,
- unsigned long flags,
size_t nmigrate_disks,
- const char **migrate_disks);
+ const char **migrate_disks,
+ unsigned long flags);
virDomainDefPtr qemuMigrationPrepareDef(virQEMUDriverPtr driver,
const char *dom_xml,
diff --git a/src/util/virtypedparam.h b/src/util/virtypedparam.h
index ac7f3a1..bc84096 100644
--- a/src/util/virtypedparam.h
+++ b/src/util/virtypedparam.h
@@ -29,7 +29,7 @@
/**
* VIR_TYPED_PARAM_MULTIPLE:
*
- * Flag indiciating that the params has multiple occurences of the parameter.
+ * Flag indicating that the params has multiple occurrences of the parameter.
* Only used as a flag for @type argument of the virTypedParamsValidate.
*/
# define VIR_TYPED_PARAM_MULTIPLE (1 << 31)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 5d10999..77de8c0 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -1236,7 +1236,7 @@ objecteventtest_LDADD = $(LDADDS)
virtypedparamtest_SOURCES = \
virtypedparamtest.c testutils.h testutils.c
-virtypedparamtest_LDADD = $(LDADDS) ../src/libvirt_util.la $(GNULIB_LIBS)
+virtypedparamtest_LDADD = $(LDADDS)
if WITH_LINUX
diff --git a/tests/virtypedparamtest.c b/tests/virtypedparamtest.c
index 2869535..b362b9b 100644
--- a/tests/virtypedparamtest.c
+++ b/tests/virtypedparamtest.c
@@ -153,7 +153,8 @@ testTypedParamsAddStringList(const void *opaque ATTRIBUTE_UNUSED)
static int
testTypedParamsGetAllStrings(const void *opaque ATTRIBUTE_UNUSED)
{
- int i, picked;
+ size_t i;
+ int picked;
int rv = -1;
char l = '1';
const char **strings = NULL;
I have it squashed into the corresponding commits. So with this - you have my ACK,
although it feels a bit weird to ACK my own patches. Therefore, I'm giving others some
time before merging this to express their feelings.
Michal