Re: [libvirt] [PATCH v4 2/2] qemu: Add support to QXL's max_outputs parameter

2016-03-30 Thread Martin Kletzander

On Wed, Mar 30, 2016 at 01:32:15PM +0200, Martin Kletzander wrote:

Historically, we added heads=1 to videos, but for example for qxl, we
did not reflect that on the command line.  Implementing that now could
mean that if user were to migrate from older to newer libvirt, the
command-line for qemu would differ.  In order for that not to happen a
migration cookie flag is introduced.

Signed-off-by: Martin Kletzander 
---
src/qemu/qemu_command.c|  8 +++
src/qemu/qemu_migration.c  | 64 --
.../qemuhotplug-agent-nopath.xml   |  5 ++
.../qemuhotplug-hotplug-base+agent-nopath.xml  | 58 
.../qemuxml2argv-video-qxl-heads.args  | 28 ++
.../qemuxml2argv-video-qxl-heads.xml   | 47 
.../qemuxml2argv-video-qxl-noheads.args| 24 
.../qemuxml2argv-video-qxl-noheads.xml | 39 +
tests/qemuxml2argvtest.c   | 16 ++
.../qemuxml2xmlout-video-qxl-heads.xml | 47 
.../qemuxml2xmlout-video-qxl-noheads.xml   | 39 +
tests/qemuxml2xmltest.c|  3 +
12 files changed, 373 insertions(+), 5 deletions(-)
create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-agent-nopath.xml
create mode 100644 
tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+agent-nopath.xml


Oh, for ... sake, don't look at the hotplug stuff, consider it not being
part of the series, I removed it from the local index and github repo.


create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-heads.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-heads.xml
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-noheads.args
create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-noheads.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-video-qxl-heads.xml
create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-video-qxl-noheads.xml

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 45c5398ad8b9..0f1657f09e99 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3985,6 +3985,14 @@ qemuBuildDeviceVideoStr(const virDomainDef *def,
/* QEMU accepts mebibytes for vgamem_mb. */
virBufferAsprintf(, ",vgamem_mb=%u", video->vgamem / 1024);
}
+
+if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_VGA_MAX_OUTPUTS) &&
+virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_MAX_OUTPUTS)) {
+if (video->heads)
+virBufferAsprintf(, ",max_outputs=%u", video->heads);
+} else {
+video->heads = 0;
+}
} else if (video->vram &&
((video->type == VIR_DOMAIN_VIDEO_TYPE_VGA &&
  virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VGAMEM)) ||
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 8bc76bf1671d..609252ae3ccc 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -87,6 +87,7 @@ enum qemuMigrationCookieFlags {
QEMU_MIGRATION_COOKIE_FLAG_NBD,
QEMU_MIGRATION_COOKIE_FLAG_STATS,
QEMU_MIGRATION_COOKIE_FLAG_MEMORY_HOTPLUG,
+QEMU_MIGRATION_COOKIE_FLAG_VIDEO_HEADS,

QEMU_MIGRATION_COOKIE_FLAG_LAST
};
@@ -100,7 +101,8 @@ VIR_ENUM_IMPL(qemuMigrationCookieFlag,
  "network",
  "nbd",
  "statistics",
-  "memory-hotplug");
+  "memory-hotplug",
+  "video-heads");

enum qemuMigrationCookieFeatures {
QEMU_MIGRATION_COOKIE_GRAPHICS  = (1 << 
QEMU_MIGRATION_COOKIE_FLAG_GRAPHICS),
@@ -110,6 +112,7 @@ enum qemuMigrationCookieFeatures {
QEMU_MIGRATION_COOKIE_NBD = (1 << QEMU_MIGRATION_COOKIE_FLAG_NBD),
QEMU_MIGRATION_COOKIE_STATS = (1 << QEMU_MIGRATION_COOKIE_FLAG_STATS),
QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG = (1 << 
QEMU_MIGRATION_COOKIE_FLAG_MEMORY_HOTPLUG),
+QEMU_MIGRATION_COOKIE_VIDEO_HEADS = (1 << 
QEMU_MIGRATION_COOKIE_FLAG_VIDEO_HEADS),
};

typedef struct _qemuMigrationCookieGraphics qemuMigrationCookieGraphics;
@@ -1386,6 +1389,9 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig,
if (flags & QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG)
mig->flagsMandatory |= QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG;

+if (flags & QEMU_MIGRATION_COOKIE_VIDEO_HEADS)
+mig->flagsMandatory |= QEMU_MIGRATION_COOKIE_VIDEO_HEADS;
+
if (!(*cookieout = qemuMigrationCookieXMLFormatStr(driver, mig)))
return -1;

@@ -3132,7 +3138,6 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver,
if (nmigrate_disks) {
if (has_drive_mirror) {
size_t i, j;
-
/* Check user requested only known disk targets. */
for (i = 0; i < nmigrate_disks; i++) {
for (j = 0; j < vm->def->ndisks; j++) {
@@ -3177,6 +3182,29 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver,
 

[libvirt] [PATCH v4 2/2] qemu: Add support to QXL's max_outputs parameter

2016-03-30 Thread Martin Kletzander
Historically, we added heads=1 to videos, but for example for qxl, we
did not reflect that on the command line.  Implementing that now could
mean that if user were to migrate from older to newer libvirt, the
command-line for qemu would differ.  In order for that not to happen a
migration cookie flag is introduced.

Signed-off-by: Martin Kletzander 
---
 src/qemu/qemu_command.c|  8 +++
 src/qemu/qemu_migration.c  | 64 --
 .../qemuhotplug-agent-nopath.xml   |  5 ++
 .../qemuhotplug-hotplug-base+agent-nopath.xml  | 58 
 .../qemuxml2argv-video-qxl-heads.args  | 28 ++
 .../qemuxml2argv-video-qxl-heads.xml   | 47 
 .../qemuxml2argv-video-qxl-noheads.args| 24 
 .../qemuxml2argv-video-qxl-noheads.xml | 39 +
 tests/qemuxml2argvtest.c   | 16 ++
 .../qemuxml2xmlout-video-qxl-heads.xml | 47 
 .../qemuxml2xmlout-video-qxl-noheads.xml   | 39 +
 tests/qemuxml2xmltest.c|  3 +
 12 files changed, 373 insertions(+), 5 deletions(-)
 create mode 100644 tests/qemuhotplugtestdata/qemuhotplug-agent-nopath.xml
 create mode 100644 
tests/qemuhotplugtestdata/qemuhotplug-hotplug-base+agent-nopath.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-heads.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-heads.xml
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-noheads.args
 create mode 100644 tests/qemuxml2argvdata/qemuxml2argv-video-qxl-noheads.xml
 create mode 100644 tests/qemuxml2xmloutdata/qemuxml2xmlout-video-qxl-heads.xml
 create mode 100644 
tests/qemuxml2xmloutdata/qemuxml2xmlout-video-qxl-noheads.xml

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 45c5398ad8b9..0f1657f09e99 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -3985,6 +3985,14 @@ qemuBuildDeviceVideoStr(const virDomainDef *def,
 /* QEMU accepts mebibytes for vgamem_mb. */
 virBufferAsprintf(, ",vgamem_mb=%u", video->vgamem / 1024);
 }
+
+if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_VGA_MAX_OUTPUTS) &&
+virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_MAX_OUTPUTS)) {
+if (video->heads)
+virBufferAsprintf(, ",max_outputs=%u", video->heads);
+} else {
+video->heads = 0;
+}
 } else if (video->vram &&
 ((video->type == VIR_DOMAIN_VIDEO_TYPE_VGA &&
   virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VGAMEM)) ||
diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c
index 8bc76bf1671d..609252ae3ccc 100644
--- a/src/qemu/qemu_migration.c
+++ b/src/qemu/qemu_migration.c
@@ -87,6 +87,7 @@ enum qemuMigrationCookieFlags {
 QEMU_MIGRATION_COOKIE_FLAG_NBD,
 QEMU_MIGRATION_COOKIE_FLAG_STATS,
 QEMU_MIGRATION_COOKIE_FLAG_MEMORY_HOTPLUG,
+QEMU_MIGRATION_COOKIE_FLAG_VIDEO_HEADS,

 QEMU_MIGRATION_COOKIE_FLAG_LAST
 };
@@ -100,7 +101,8 @@ VIR_ENUM_IMPL(qemuMigrationCookieFlag,
   "network",
   "nbd",
   "statistics",
-  "memory-hotplug");
+  "memory-hotplug",
+  "video-heads");

 enum qemuMigrationCookieFeatures {
 QEMU_MIGRATION_COOKIE_GRAPHICS  = (1 << 
QEMU_MIGRATION_COOKIE_FLAG_GRAPHICS),
@@ -110,6 +112,7 @@ enum qemuMigrationCookieFeatures {
 QEMU_MIGRATION_COOKIE_NBD = (1 << QEMU_MIGRATION_COOKIE_FLAG_NBD),
 QEMU_MIGRATION_COOKIE_STATS = (1 << QEMU_MIGRATION_COOKIE_FLAG_STATS),
 QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG = (1 << 
QEMU_MIGRATION_COOKIE_FLAG_MEMORY_HOTPLUG),
+QEMU_MIGRATION_COOKIE_VIDEO_HEADS = (1 << 
QEMU_MIGRATION_COOKIE_FLAG_VIDEO_HEADS),
 };

 typedef struct _qemuMigrationCookieGraphics qemuMigrationCookieGraphics;
@@ -1386,6 +1389,9 @@ qemuMigrationBakeCookie(qemuMigrationCookiePtr mig,
 if (flags & QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG)
 mig->flagsMandatory |= QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG;

+if (flags & QEMU_MIGRATION_COOKIE_VIDEO_HEADS)
+mig->flagsMandatory |= QEMU_MIGRATION_COOKIE_VIDEO_HEADS;
+
 if (!(*cookieout = qemuMigrationCookieXMLFormatStr(driver, mig)))
 return -1;

@@ -3132,7 +3138,6 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver,
 if (nmigrate_disks) {
 if (has_drive_mirror) {
 size_t i, j;
-
 /* Check user requested only known disk targets. */
 for (i = 0; i < nmigrate_disks; i++) {
 for (j = 0; j < vm->def->ndisks; j++) {
@@ -3177,6 +3182,29 @@ qemuMigrationBeginPhase(virQEMUDriverPtr driver,
  vm->newDef && virDomainDefHasMemoryHotplug(vm->newDef)))
 cookieFlags |= QEMU_MIGRATION_COOKIE_MEMORY_HOTPLUG;

+/*
+ * If there is at least one QXL video