The logic setting a device default should be in the post parse function
of individual driver code.
Signed-off-by: Rafael Fonseca <r4f4rfs(a)gmail.com>
---
src/conf/domain_conf.c | 2 +-
src/libxl/libxl_domain.c | 60 ++++++++++++++++++++++++----------------
2 files changed, 37 insertions(+), 25 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 957989e848..04636e8694 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -15716,7 +15716,6 @@ virDomainVideoDefaultType(const virDomainDef *def)
{
switch ((virDomainVirtType)def->virtType) {
case VIR_DOMAIN_VIRT_TEST:
- case VIR_DOMAIN_VIRT_XEN:
if (def->os.type == VIR_DOMAIN_OSTYPE_XEN ||
def->os.type == VIR_DOMAIN_OSTYPE_LINUX)
return VIR_DOMAIN_VIDEO_TYPE_XEN;
@@ -15737,6 +15736,7 @@ virDomainVideoDefaultType(const virDomainDef *def)
return VIR_DOMAIN_VIDEO_TYPE_VGA;
else
return VIR_DOMAIN_VIDEO_TYPE_PARALLELS;
+ case VIR_DOMAIN_VIRT_XEN:
case VIR_DOMAIN_VIRT_BHYVE:
case VIR_DOMAIN_VIRT_QEMU:
case VIR_DOMAIN_VIRT_KQEMU:
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index e3da9f777d..cc53a765e1 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -315,31 +315,43 @@ libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
pcisrc->backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_XEN;
}
- if (dev->type == VIR_DOMAIN_DEVICE_VIDEO && def->os.type ==
VIR_DOMAIN_OSTYPE_HVM) {
- int dm_type = libxlDomainGetEmulatorType(def);
-
- switch (dev->data.video->type) {
- case VIR_DOMAIN_VIDEO_TYPE_VGA:
- case VIR_DOMAIN_VIDEO_TYPE_XEN:
- if (dev->data.video->vram == 0) {
- if (dm_type == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN)
- dev->data.video->vram = 16 * 1024;
- else
- dev->data.video->vram = 8 * 1024;
- }
- break;
- case VIR_DOMAIN_VIDEO_TYPE_CIRRUS:
- if (dev->data.video->vram == 0) {
- if (dm_type == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN)
- dev->data.video->vram = 8 * 1024;
- else
- dev->data.video->vram = 4 * 1024;
+ if (dev->type == VIR_DOMAIN_DEVICE_VIDEO) {
+ if (dev->data.video->type == VIR_DOMAIN_VIDEO_TYPE_DEFAULT) {
+ if (def->os.type == VIR_DOMAIN_OSTYPE_XEN ||
+ def->os.type == VIR_DOMAIN_OSTYPE_LINUX)
+ dev->data.video->type = VIR_DOMAIN_VIDEO_TYPE_XEN;
+ else if (ARCH_IS_PPC64(def->os.arch))
+ dev->data.video->type = VIR_DOMAIN_VIDEO_TYPE_VGA;
+ else
+ dev->data.video->type = VIR_DOMAIN_VIDEO_TYPE_CIRRUS;
+ }
+
+ if (def->os.type == VIR_DOMAIN_OSTYPE_HVM) {
+ int dm_type = libxlDomainGetEmulatorType(def);
+
+ switch (dev->data.video->type) {
+ case VIR_DOMAIN_VIDEO_TYPE_VGA:
+ case VIR_DOMAIN_VIDEO_TYPE_XEN:
+ if (dev->data.video->vram == 0) {
+ if (dm_type == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN)
+ dev->data.video->vram = 16 * 1024;
+ else
+ dev->data.video->vram = 8 * 1024;
+ }
+ break;
+ case VIR_DOMAIN_VIDEO_TYPE_CIRRUS:
+ if (dev->data.video->vram == 0) {
+ if (dm_type == LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN)
+ dev->data.video->vram = 8 * 1024;
+ else
+ dev->data.video->vram = 4 * 1024;
+ }
+ break;
+ case VIR_DOMAIN_VIDEO_TYPE_QXL:
+ if (dev->data.video->vram == 0)
+ dev->data.video->vram = 128 * 1024;
+ break;
}
- break;
- case VIR_DOMAIN_VIDEO_TYPE_QXL:
- if (dev->data.video->vram == 0)
- dev->data.video->vram = 128 * 1024;
- break;
}
}
--
2.25.1