[libvirt] [PATCH] qemu_process: move graphics validation into separate function

Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_process.c | 56 +++++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 1f56883..b360f6b 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4409,6 +4409,38 @@ qemuProcessStartWarnShmem(virDomainObjPtr vm) } } + +static int +qemuProcessStartValidateGraphics(virDomainObjPtr vm) +{ + size_t i; + + for (i = 0; i < vm->def->ngraphics; i++) { + virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; + + switch (graphics->type) { + case VIR_DOMAIN_GRAPHICS_TYPE_VNC: + case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: + if (graphics->nListens > 1) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("QEMU does not support multiple listens for " + "one graphics device.")); + return -1; + } + break; + + case VIR_DOMAIN_GRAPHICS_TYPE_SDL: + case VIR_DOMAIN_GRAPHICS_TYPE_RDP: + case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP: + case VIR_DOMAIN_GRAPHICS_TYPE_LAST: + break; + } + } + + return 0; +} + + static int qemuProcessStartValidateXML(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -4456,8 +4488,6 @@ qemuProcessStartValidate(virQEMUDriverPtr driver, virCapsPtr caps, unsigned int flags) { - size_t i; - if (!(flags & VIR_QEMU_PROCESS_START_PRETEND)) { if (vm->def->virtType == VIR_DOMAIN_VIRT_KVM) { VIR_DEBUG("Checking for KVM availability"); @@ -4484,27 +4514,7 @@ qemuProcessStartValidate(virQEMUDriverPtr driver, qemuProcessStartWarnShmem(vm); - for (i = 0; i < vm->def->ngraphics; i++) { - virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; - - switch (graphics->type) { - case VIR_DOMAIN_GRAPHICS_TYPE_VNC: - case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: - if (graphics->nListens > 1) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("QEMU does not support multiple listens for " - "one graphics device.")); - return -1; - } - break; - - case VIR_DOMAIN_GRAPHICS_TYPE_SDL: - case VIR_DOMAIN_GRAPHICS_TYPE_RDP: - case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP: - case VIR_DOMAIN_GRAPHICS_TYPE_LAST: - break; - } - } + qemuProcessStartValidateGraphics(vm); return 0; } -- 2.10.0

On 09/21/2016 11:40 AM, Pavel Hrdina wrote:
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_process.c | 56 +++++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 23 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 1f56883..b360f6b 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4409,6 +4409,38 @@ qemuProcessStartWarnShmem(virDomainObjPtr vm) } }
+ +static int +qemuProcessStartValidateGraphics(virDomainObjPtr vm) +{ + size_t i; + + for (i = 0; i < vm->def->ngraphics; i++) { + virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; + + switch (graphics->type) { + case VIR_DOMAIN_GRAPHICS_TYPE_VNC: + case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: + if (graphics->nListens > 1) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("QEMU does not support multiple listens for " + "one graphics device.")); + return -1; + } + break; + + case VIR_DOMAIN_GRAPHICS_TYPE_SDL: + case VIR_DOMAIN_GRAPHICS_TYPE_RDP: + case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP: + case VIR_DOMAIN_GRAPHICS_TYPE_LAST: + break; + } + } + + return 0; +} + + static int qemuProcessStartValidateXML(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -4456,8 +4488,6 @@ qemuProcessStartValidate(virQEMUDriverPtr driver, virCapsPtr caps, unsigned int flags) { - size_t i; - if (!(flags & VIR_QEMU_PROCESS_START_PRETEND)) { if (vm->def->virtType == VIR_DOMAIN_VIRT_KVM) { VIR_DEBUG("Checking for KVM availability"); @@ -4484,27 +4514,7 @@ qemuProcessStartValidate(virQEMUDriverPtr driver,
qemuProcessStartWarnShmem(vm);
- for (i = 0; i < vm->def->ngraphics; i++) { - virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; - - switch (graphics->type) { - case VIR_DOMAIN_GRAPHICS_TYPE_VNC: - case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: - if (graphics->nListens > 1) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("QEMU does not support multiple listens for " - "one graphics device.")); - return -1; - } - break; - - case VIR_DOMAIN_GRAPHICS_TYPE_SDL: - case VIR_DOMAIN_GRAPHICS_TYPE_RDP: - case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP: - case VIR_DOMAIN_GRAPHICS_TYPE_LAST: - break; - } - } + qemuProcessStartValidateGraphics(vm);
return qemuProcessStartValidateGraphics(vm); otherwise a return -1 from that call is lost/ignored and changed into return 0 below.. ACK w/ that adjustment John
return 0; }

On Wed, Sep 21, 2016 at 04:58:55PM -0400, John Ferlan wrote:
On 09/21/2016 11:40 AM, Pavel Hrdina wrote:
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/qemu/qemu_process.c | 56 +++++++++++++++++++++++++++++-------------------- 1 file changed, 33 insertions(+), 23 deletions(-)
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 1f56883..b360f6b 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4409,6 +4409,38 @@ qemuProcessStartWarnShmem(virDomainObjPtr vm) } }
+ +static int +qemuProcessStartValidateGraphics(virDomainObjPtr vm) +{ + size_t i; + + for (i = 0; i < vm->def->ngraphics; i++) { + virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; + + switch (graphics->type) { + case VIR_DOMAIN_GRAPHICS_TYPE_VNC: + case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: + if (graphics->nListens > 1) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("QEMU does not support multiple listens for " + "one graphics device.")); + return -1; + } + break; + + case VIR_DOMAIN_GRAPHICS_TYPE_SDL: + case VIR_DOMAIN_GRAPHICS_TYPE_RDP: + case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP: + case VIR_DOMAIN_GRAPHICS_TYPE_LAST: + break; + } + } + + return 0; +} + + static int qemuProcessStartValidateXML(virQEMUDriverPtr driver, virDomainObjPtr vm, @@ -4456,8 +4488,6 @@ qemuProcessStartValidate(virQEMUDriverPtr driver, virCapsPtr caps, unsigned int flags) { - size_t i; - if (!(flags & VIR_QEMU_PROCESS_START_PRETEND)) { if (vm->def->virtType == VIR_DOMAIN_VIRT_KVM) { VIR_DEBUG("Checking for KVM availability"); @@ -4484,27 +4514,7 @@ qemuProcessStartValidate(virQEMUDriverPtr driver,
qemuProcessStartWarnShmem(vm);
- for (i = 0; i < vm->def->ngraphics; i++) { - virDomainGraphicsDefPtr graphics = vm->def->graphics[i]; - - switch (graphics->type) { - case VIR_DOMAIN_GRAPHICS_TYPE_VNC: - case VIR_DOMAIN_GRAPHICS_TYPE_SPICE: - if (graphics->nListens > 1) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("QEMU does not support multiple listens for " - "one graphics device.")); - return -1; - } - break; - - case VIR_DOMAIN_GRAPHICS_TYPE_SDL: - case VIR_DOMAIN_GRAPHICS_TYPE_RDP: - case VIR_DOMAIN_GRAPHICS_TYPE_DESKTOP: - case VIR_DOMAIN_GRAPHICS_TYPE_LAST: - break; - } - } + qemuProcessStartValidateGraphics(vm);
return qemuProcessStartValidateGraphics(vm);
otherwise a return -1 from that call is lost/ignored and changed into return 0 below..
ACK w/ that adjustment
Ouch, nice catch, thanks, I'll fix it and push it shortly. Pavel
participants (2)
-
John Ferlan
-
Pavel Hrdina