mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-24 05:25:18 +00:00
qemu_command: separate code for video device via -vga attribute
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
33af92a91c
commit
55d5a9bc06
@ -4330,35 +4330,15 @@ qemuBuildDeviceVideoStr(const virDomainDef *def,
|
||||
|
||||
|
||||
static int
|
||||
qemuBuildVideoCommandLine(virCommandPtr cmd,
|
||||
qemuBuildVgaVideoCommand(virCommandPtr cmd,
|
||||
const virDomainDef *def,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
size_t i;
|
||||
int primaryVideoType;
|
||||
|
||||
if (!def->videos)
|
||||
return 0;
|
||||
|
||||
primaryVideoType = def->videos[0]->type;
|
||||
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY)) {
|
||||
for (i = 0; i < def->nvideos; i++) {
|
||||
char *str;
|
||||
virCommandAddArg(cmd, "-device");
|
||||
if (!(str = qemuBuildDeviceVideoStr(def, def->videos[i],
|
||||
qemuCaps)))
|
||||
return -1;
|
||||
|
||||
virCommandAddArg(cmd, str);
|
||||
VIR_FREE(str);
|
||||
}
|
||||
} else {
|
||||
const char *vgastr = qemuVideoTypeToString(primaryVideoType);
|
||||
const char *vgastr = qemuVideoTypeToString(def->videos[0]->type);
|
||||
if (!vgastr || STREQ(vgastr, "")) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("invalid model for video type '%s'"),
|
||||
virDomainVideoTypeToString(primaryVideoType));
|
||||
virDomainVideoTypeToString(def->videos[0]->type));
|
||||
return -1;
|
||||
}
|
||||
|
||||
@ -4375,7 +4355,7 @@ qemuBuildVideoCommandLine(virCommandPtr cmd,
|
||||
* See 'Graphics Devices' section in docs/qdev-device-use.txt in
|
||||
* QEMU repository.
|
||||
*/
|
||||
const char *dev = qemuDeviceVideoTypeToString(primaryVideoType);
|
||||
const char *dev = qemuDeviceVideoTypeToString(def->videos[0]->type);
|
||||
|
||||
if (def->videos[0]->type == VIR_DOMAIN_VIDEO_TYPE_QXL &&
|
||||
(def->videos[0]->vram || def->videos[0]->ram)) {
|
||||
@ -4409,9 +4389,9 @@ qemuBuildVideoCommandLine(virCommandPtr cmd,
|
||||
}
|
||||
|
||||
if (def->videos[0]->vram &&
|
||||
((primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VGA &&
|
||||
((def->videos[0]->type == VIR_DOMAIN_VIDEO_TYPE_VGA &&
|
||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VGA_VGAMEM)) ||
|
||||
(primaryVideoType == VIR_DOMAIN_VIDEO_TYPE_VMVGA &&
|
||||
(def->videos[0]->type == VIR_DOMAIN_VIDEO_TYPE_VMVGA &&
|
||||
virQEMUCapsGet(qemuCaps, QEMU_CAPS_VMWARE_SVGA_VGAMEM)))) {
|
||||
unsigned int vram = def->videos[0]->vram;
|
||||
|
||||
@ -4420,6 +4400,35 @@ qemuBuildVideoCommandLine(virCommandPtr cmd,
|
||||
dev, vram / 1024);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
qemuBuildVideoCommandLine(virCommandPtr cmd,
|
||||
const virDomainDef *def,
|
||||
virQEMUCapsPtr qemuCaps)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
if (!def->videos)
|
||||
return 0;
|
||||
|
||||
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIDEO_PRIMARY)) {
|
||||
for (i = 0; i < def->nvideos; i++) {
|
||||
char *str;
|
||||
virCommandAddArg(cmd, "-device");
|
||||
if (!(str = qemuBuildDeviceVideoStr(def, def->videos[i],
|
||||
qemuCaps)))
|
||||
return -1;
|
||||
|
||||
virCommandAddArg(cmd, str);
|
||||
VIR_FREE(str);
|
||||
}
|
||||
} else {
|
||||
if (qemuBuildVgaVideoCommand(cmd, def, qemuCaps) < 0)
|
||||
return -1;
|
||||
|
||||
for (i = 1; i < def->nvideos; i++) {
|
||||
char *str;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user