qemu_command: remove xenner leftover from video device code

Qemu supports *xen* video device only with XEN and this code was part
of xenner code.  We dropped support for xenner in commit de9be0a.

Before this patch if you used 'xen' video type you ended up with
domain without any video device at all.  Now we don't allow to start
such domain.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
Pavel Hrdina 2016-10-11 17:37:45 +02:00
parent 3632ddc766
commit 971d552e68
1 changed files with 85 additions and 89 deletions

View File

@ -96,7 +96,7 @@ VIR_ENUM_IMPL(qemuVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
"std", "std",
"cirrus", "cirrus",
"vmware", "vmware",
"", /* no arg needed for xen */ "", /* don't support xen */
"", /* don't support vbox */ "", /* don't support vbox */
"qxl", "qxl",
"", /* don't support parallels */ "", /* don't support parallels */
@ -108,7 +108,7 @@ VIR_ENUM_IMPL(qemuDeviceVideo, VIR_DOMAIN_VIDEO_TYPE_LAST,
"VGA", "VGA",
"cirrus-vga", "cirrus-vga",
"vmware-svga", "vmware-svga",
"", /* no device for xen */ "", /* don't support xen */
"", /* don't support vbox */ "", /* don't support vbox */
"qxl-vga", "qxl-vga",
"", /* don't support parallels */ "", /* don't support parallels */
@ -4419,103 +4419,99 @@ qemuBuildVideoCommandLine(virCommandPtr cmd,
VIR_FREE(str); VIR_FREE(str);
} }
} else { } else {
if (primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_XEN) { if ((primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_QXL) &&
/* nothing - vga has no effect on Xen pvfb */ !virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_QXL)) {
} else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
if ((primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_QXL) && _("This QEMU does not support QXL graphics adapters"));
!virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_QXL)) { return -1;
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", }
_("This QEMU does not support QXL graphics adapters"));
const char *vgastr = qemuVideoTypeToString(primaryVideoType);
if (!vgastr || STREQ(vgastr, "")) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("video type %s is not supported with QEMU"),
virDomainVideoTypeToString(primaryVideoType));
return -1;
}
virCommandAddArgList(cmd, "-vga", vgastr, NULL);
/* If we cannot use --device option to specify the video device
* in QEMU we will fallback to the old --vga option. To get the
* correct device name for the --vga option the 'qemuVideo' is
* used, but to set some device attributes we need to use the
* --global option and for that we need to specify the device
* name the same as for --device option and for that we need to
* use 'qemuDeviceVideo'.
*
* See 'Graphics Devices' section in docs/qdev-device-use.txt in
* QEMU repository.
*/
const char *dev = qemuDeviceVideoTypeToString(primaryVideoType);
if (def->videos[0]->type == VIR_DOMAIN_VIDEO_TYPE_QXL &&
(def->videos[0]->vram || def->videos[0]->ram)) {
unsigned int ram = def->videos[0]->ram;
unsigned int vram = def->videos[0]->vram;
unsigned int vram64 = def->videos[0]->vram64;
unsigned int vgamem = def->videos[0]->vgamem;
if (vram > (UINT_MAX / 1024)) {
virReportError(VIR_ERR_OVERFLOW,
_("value for 'vram' must be less than '%u'"),
UINT_MAX / 1024);
return -1;
}
if (ram > (UINT_MAX / 1024)) {
virReportError(VIR_ERR_OVERFLOW,
_("value for 'ram' must be less than '%u'"),
UINT_MAX / 1024);
return -1; return -1;
} }
const char *vgastr = qemuVideoTypeToString(primaryVideoType); if (ram) {
if (!vgastr || STREQ(vgastr, "")) { virCommandAddArg(cmd, "-global");
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virCommandAddArgFormat(cmd, "%s.ram_size=%u",
_("video type %s is not supported with QEMU"), dev, ram * 1024);
virDomainVideoTypeToString(primaryVideoType));
return -1;
} }
if (vram) {
virCommandAddArgList(cmd, "-vga", vgastr, NULL); virCommandAddArg(cmd, "-global");
virCommandAddArgFormat(cmd, "%s.vram_size=%u",
/* If we cannot use --device option to specify the video device dev, vram * 1024);
* in QEMU we will fallback to the old --vga option. To get the
* correct device name for the --vga option the 'qemuVideo' is
* used, but to set some device attributes we need to use the
* --global option and for that we need to specify the device
* name the same as for --device option and for that we need to
* use 'qemuDeviceVideo'.
*
* See 'Graphics Devices' section in docs/qdev-device-use.txt in
* QEMU repository.
*/
const char *dev = qemuDeviceVideoTypeToString(primaryVideoType);
if (def->videos[0]->type == VIR_DOMAIN_VIDEO_TYPE_QXL &&
(def->videos[0]->vram || def->videos[0]->ram)) {
unsigned int ram = def->videos[0]->ram;
unsigned int vram = def->videos[0]->vram;
unsigned int vram64 = def->videos[0]->vram64;
unsigned int vgamem = def->videos[0]->vgamem;
if (vram > (UINT_MAX / 1024)) {
virReportError(VIR_ERR_OVERFLOW,
_("value for 'vram' must be less than '%u'"),
UINT_MAX / 1024);
return -1;
}
if (ram > (UINT_MAX / 1024)) {
virReportError(VIR_ERR_OVERFLOW,
_("value for 'ram' must be less than '%u'"),
UINT_MAX / 1024);
return -1;
}
if (ram) {
virCommandAddArg(cmd, "-global");
virCommandAddArgFormat(cmd, "%s.ram_size=%u",
dev, ram * 1024);
}
if (vram) {
virCommandAddArg(cmd, "-global");
virCommandAddArgFormat(cmd, "%s.vram_size=%u",
dev, vram * 1024);
}
if (vram64 &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_VGA_VRAM64)) {
virCommandAddArg(cmd, "-global");
virCommandAddArgFormat(cmd, "%s.vram64_size_mb=%u",
dev, vram64 / 1024);
}
if (vgamem &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_VGA_VGAMEM)) {
virCommandAddArg(cmd, "-global");
virCommandAddArgFormat(cmd, "%s.vgamem_mb=%u",
dev, vgamem / 1024);
}
} }
if (vram64 &&
if (def->videos[0]->vram && virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_VGA_VRAM64)) {
((primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VGA && virCommandAddArg(cmd, "-global");
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VGAMEM)) || virCommandAddArgFormat(cmd, "%s.vram64_size_mb=%u",
(primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VMVGA && dev, vram64 / 1024);
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VMWARE_SVGA_VGAMEM)))) { }
unsigned int vram = def->videos[0]->vram; if (vgamem &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_QXL_VGA_VGAMEM)) {
if (vram < 1024) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
"%s", _("value for 'vgamem' must be at "
"least 1 MiB (1024 KiB)"));
return -1;
}
virCommandAddArg(cmd, "-global"); virCommandAddArg(cmd, "-global");
virCommandAddArgFormat(cmd, "%s.vgamem_mb=%u", virCommandAddArgFormat(cmd, "%s.vgamem_mb=%u",
dev, vram / 1024); dev, vgamem / 1024);
} }
} }
if (def->videos[0]->vram &&
((primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VGA &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VGAMEM)) ||
(primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VMVGA &&
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VMWARE_SVGA_VGAMEM)))) {
unsigned int vram = def->videos[0]->vram;
if (vram < 1024) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
"%s", _("value for 'vgamem' must be at "
"least 1 MiB (1024 KiB)"));
return -1;
}
virCommandAddArg(cmd, "-global");
virCommandAddArgFormat(cmd, "%s.vgamem_mb=%u",
dev, vram / 1024);
}
for (i = 1; i < def->nvideos; i++) { for (i = 1; i < def->nvideos; i++) {
char *str; char *str;
if (def->videos[i]->type != VIR_DOMAIN_VIDEO_TYPE_QXL) { if (def->videos[i]->type != VIR_DOMAIN_VIDEO_TYPE_QXL) {