Replace all three-state (default/yes/no) enums with it: virDomainBootMenu virDomainPMState virDomainGraphicsSpiceClipboardCopypaste virDomainGraphicsSpiceAgentFileTransfer --- src/conf/domain_conf.c | 54 ++++++++++++++---------------------------------- src/conf/domain_conf.h | 45 ++++++---------------------------------- src/libvirt_private.syms | 8 ------- src/qemu/qemu_command.c | 22 ++++++++++---------- src/qemu/qemu_driver.c | 4 ++-- 5 files changed, 35 insertions(+), 98 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 1d83f13..113bd10 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -134,7 +134,7 @@ VIR_ENUM_IMPL(virDomainBoot, VIR_DOMAIN_BOOT_LAST, "hd", "network") -VIR_ENUM_IMPL(virDomainBootMenu, VIR_DOMAIN_BOOT_MENU_LAST, +VIR_ENUM_IMPL(virDomainYesNo, VIR_DOMAIN_YES_NO_LAST, "default", "yes", "no") @@ -180,11 +180,6 @@ VIR_ENUM_IMPL(virDomainLockFailure, VIR_DOMAIN_LOCK_FAILURE_LAST, "pause", "ignore") -VIR_ENUM_IMPL(virDomainPMState, VIR_DOMAIN_PM_STATE_LAST, - "default", - "yes", - "no") - VIR_ENUM_IMPL(virDomainDevice, VIR_DOMAIN_DEVICE_LAST, "none", "disk", @@ -576,18 +571,6 @@ VIR_ENUM_IMPL(virDomainGraphicsSpiceStreamingMode, "all", "off"); -VIR_ENUM_IMPL(virDomainGraphicsSpiceClipboardCopypaste, - VIR_DOMAIN_GRAPHICS_SPICE_CLIPBOARD_COPYPASTE_LAST, - "default", - "yes", - "no"); - -VIR_ENUM_IMPL(virDomainGraphicsSpiceAgentFileTransfer, - VIR_DOMAIN_GRAPHICS_SPICE_AGENT_FILE_TRANSFER_LAST, - "default", - "yes", - "no"); - VIR_ENUM_IMPL(virDomainHostdevMode, VIR_DOMAIN_HOSTDEV_MODE_LAST, "subsystem", "capabilities") @@ -8789,7 +8772,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, } if ((copypasteVal = - virDomainGraphicsSpiceClipboardCopypasteTypeFromString(copypaste)) <= 0) { + virDomainYesNoTypeFromString(copypaste)) <= 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown copypaste value '%s'"), copypaste); VIR_FREE(copypaste); @@ -8809,7 +8792,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, } if ((enableVal = - virDomainGraphicsSpiceAgentFileTransferTypeFromString(enable)) <= 0) { + virDomainYesNoTypeFromString(enable)) <= 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown enable value '%s'"), enable); VIR_FREE(enable); @@ -9916,7 +9899,7 @@ virDomainPMStateParseXML(xmlXPathContextPtr ctxt, int ret = -1; char *tmp = virXPathString(xpath, ctxt); if (tmp) { - *val = virDomainPMStateTypeFromString(tmp); + *val = virDomainYesNoTypeFromString(tmp); if (*val < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown PM state value %s"), tmp); @@ -10879,14 +10862,14 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, tmp = virXPathString("string(./os/bootmenu[1]/@enable)", ctxt); if (tmp) { - def->os.bootmenu = virDomainBootMenuTypeFromString(tmp); + def->os.bootmenu = virDomainYesNoTypeFromString(tmp); if (def->os.bootmenu <= 0) { /* In order not to break misconfigured machines, this * should not emit an error, but rather set the bootmenu * to disabled */ VIR_WARN("disabling bootmenu due to unknown option '%s'", tmp); - def->os.bootmenu = VIR_DOMAIN_BOOT_MENU_DISABLED; + def->os.bootmenu = VIR_DOMAIN_YES_NO_DISABLED; } VIR_FREE(tmp); } @@ -10901,9 +10884,9 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, "for useserial")); goto cleanup; } - def->os.bios.useserial = VIR_DOMAIN_BIOS_USESERIAL_YES; + def->os.bios.useserial = VIR_DOMAIN_YES_NO_ENABLED; } else { - def->os.bios.useserial = VIR_DOMAIN_BIOS_USESERIAL_NO; + def->os.bios.useserial = VIR_DOMAIN_YES_NO_DISABLED; } VIR_FREE(tmp); } @@ -16943,10 +16926,10 @@ virDomainGraphicsDefFormat(virBufferPtr buf, virDomainGraphicsSpiceMouseModeTypeToString(def->data.spice.mousemode)); if (def->data.spice.copypaste) virBufferAsprintf(buf, "<clipboard copypaste='%s'/>\n", - virDomainGraphicsSpiceClipboardCopypasteTypeToString(def->data.spice.copypaste)); + virDomainYesNoTypeToString(def->data.spice.copypaste)); if (def->data.spice.filetransfer) virBufferAsprintf(buf, "<filetransfer enable='%s'/>\n", - virDomainGraphicsSpiceAgentFileTransferTypeToString(def->data.spice.filetransfer)); + virDomainYesNoTypeToString(def->data.spice.filetransfer)); } if (children) { @@ -17528,20 +17511,15 @@ virDomainDefFormatInternal(virDomainDefPtr def, virBufferAsprintf(buf, "<boot dev='%s'/>\n", boottype); } - if (def->os.bootmenu != VIR_DOMAIN_BOOT_MENU_DEFAULT) { - const char *enabled = (def->os.bootmenu == - VIR_DOMAIN_BOOT_MENU_ENABLED ? "yes" - : "no"); - virBufferAsprintf(buf, "<bootmenu enable='%s'/>\n", enabled); - } + if (def->os.bootmenu) + virBufferAsprintf(buf, "<bootmenu enable='%s'/>\n", + virDomainYesNoTypeToString(def->os.bootmenu)); if (def->os.bios.useserial || def->os.bios.rt_set) { virBufferAddLit(buf, "<bios"); if (def->os.bios.useserial) virBufferAsprintf(buf, " useserial='%s'", - (def->os.bios.useserial == - VIR_DOMAIN_BIOS_USESERIAL_YES ? "yes" - : "no")); + virDomainYesNoTypeToString(def->os.bios.useserial)); if (def->os.bios.rt_set) virBufferAsprintf(buf, " rebootTimeout='%d'", def->os.bios.rt_delay); @@ -17766,11 +17744,11 @@ virDomainDefFormatInternal(virDomainDefPtr def, virBufferAdjustIndent(buf, 2); if (def->pm.s3) { virBufferAsprintf(buf, "<suspend-to-mem enabled='%s'/>\n", - virDomainPMStateTypeToString(def->pm.s3)); + virDomainYesNoTypeToString(def->pm.s3)); } if (def->pm.s4) { virBufferAsprintf(buf, "<suspend-to-disk enabled='%s'/>\n", - virDomainPMStateTypeToString(def->pm.s4)); + virDomainYesNoTypeToString(def->pm.s4)); } virBufferAdjustIndent(buf, -2); virBufferAddLit(buf, "</pm>\n"); diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 32674e0..29c63af 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -1337,22 +1337,6 @@ typedef enum { } virDomainGraphicsSpiceStreamingMode; typedef enum { - VIR_DOMAIN_GRAPHICS_SPICE_CLIPBOARD_COPYPASTE_DEFAULT = 0, - VIR_DOMAIN_GRAPHICS_SPICE_CLIPBOARD_COPYPASTE_YES, - VIR_DOMAIN_GRAPHICS_SPICE_CLIPBOARD_COPYPASTE_NO, - - VIR_DOMAIN_GRAPHICS_SPICE_CLIPBOARD_COPYPASTE_LAST -} virDomainGraphicsSpiceClipboardCopypaste; - -typedef enum { - VIR_DOMAIN_GRAPHICS_SPICE_AGENT_FILE_TRANSFER_DEFAULT = 0, - VIR_DOMAIN_GRAPHICS_SPICE_AGENT_FILE_TRANSFER_YES, - VIR_DOMAIN_GRAPHICS_SPICE_AGENT_FILE_TRANSFER_NO, - - VIR_DOMAIN_GRAPHICS_SPICE_AGENT_FILE_TRANSFER_LAST -} virDomainGraphicsSpiceAgentFileTransfer; - -typedef enum { VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NONE = 0, VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_ADDRESS, VIR_DOMAIN_GRAPHICS_LISTEN_TYPE_NETWORK, @@ -1512,12 +1496,12 @@ typedef enum { } virDomainBootOrder; typedef enum { - VIR_DOMAIN_BOOT_MENU_DEFAULT = 0, - VIR_DOMAIN_BOOT_MENU_ENABLED, - VIR_DOMAIN_BOOT_MENU_DISABLED, + VIR_DOMAIN_YES_NO_DEFAULT = 0, + VIR_DOMAIN_YES_NO_ENABLED, + VIR_DOMAIN_YES_NO_DISABLED, - VIR_DOMAIN_BOOT_MENU_LAST -} virDomainBootMenu; + VIR_DOMAIN_YES_NO_LAST +} virDomainYesNo; typedef enum { VIR_DOMAIN_FEATURE_ACPI, @@ -1580,20 +1564,6 @@ typedef enum { VIR_ENUM_DECL(virDomainLockFailure) -typedef enum { - VIR_DOMAIN_PM_STATE_DEFAULT = 0, - VIR_DOMAIN_PM_STATE_ENABLED, - VIR_DOMAIN_PM_STATE_DISABLED, - - VIR_DOMAIN_PM_STATE_LAST -} virDomainPMState; - -typedef enum { - VIR_DOMAIN_BIOS_USESERIAL_DEFAULT = 0, - VIR_DOMAIN_BIOS_USESERIAL_YES, - VIR_DOMAIN_BIOS_USESERIAL_NO -} virDomainBIOSUseserial; - typedef struct _virDomainBIOSDef virDomainBIOSDef; typedef virDomainBIOSDef *virDomainBIOSDefPtr; struct _virDomainBIOSDef { @@ -2531,12 +2501,11 @@ VIR_ENUM_DECL(virDomainTaint) VIR_ENUM_DECL(virDomainVirt) VIR_ENUM_DECL(virDomainBoot) -VIR_ENUM_DECL(virDomainBootMenu) +VIR_ENUM_DECL(virDomainYesNo) VIR_ENUM_DECL(virDomainFeature) VIR_ENUM_DECL(virDomainFeatureState) VIR_ENUM_DECL(virDomainLifecycle) VIR_ENUM_DECL(virDomainLifecycleCrash) -VIR_ENUM_DECL(virDomainPMState) VIR_ENUM_DECL(virDomainDevice) VIR_ENUM_DECL(virDomainDeviceAddress) VIR_ENUM_DECL(virDomainDiskDevice) @@ -2590,7 +2559,6 @@ VIR_ENUM_DECL(virDomainInputBus) VIR_ENUM_DECL(virDomainGraphics) VIR_ENUM_DECL(virDomainGraphicsListen) VIR_ENUM_DECL(virDomainGraphicsAuthConnected) -VIR_ENUM_DECL(virDomainGraphicsSpiceAgentFileTransfer) VIR_ENUM_DECL(virDomainGraphicsSpiceChannelName) VIR_ENUM_DECL(virDomainGraphicsSpiceChannelMode) VIR_ENUM_DECL(virDomainGraphicsSpiceImageCompression) @@ -2598,7 +2566,6 @@ VIR_ENUM_DECL(virDomainGraphicsSpiceJpegCompression) VIR_ENUM_DECL(virDomainGraphicsSpiceZlibCompression) VIR_ENUM_DECL(virDomainGraphicsSpicePlaybackCompression) VIR_ENUM_DECL(virDomainGraphicsSpiceStreamingMode) -VIR_ENUM_DECL(virDomainGraphicsSpiceClipboardCopypaste) VIR_ENUM_DECL(virDomainGraphicsSpiceMouseMode) VIR_ENUM_DECL(virDomainGraphicsVNCSharePolicy) VIR_ENUM_DECL(virDomainHyperv) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index e59ea4c..d1adaa2 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -145,8 +145,6 @@ virDiskNameToIndex; virDomainActualNetDefFree; virDomainBlockedReasonTypeFromString; virDomainBlockedReasonTypeToString; -virDomainBootMenuTypeFromString; -virDomainBootMenuTypeToString; virDomainChrConsoleTargetTypeFromString; virDomainChrConsoleTargetTypeToString; virDomainChrDefForeach; @@ -271,14 +269,10 @@ virDomainGraphicsListenGetType; virDomainGraphicsListenSetAddress; virDomainGraphicsListenSetNetwork; virDomainGraphicsListenSetType; -virDomainGraphicsSpiceAgentFileTransferTypeFromString; -virDomainGraphicsSpiceAgentFileTransferTypeToString; virDomainGraphicsSpiceChannelModeTypeFromString; virDomainGraphicsSpiceChannelModeTypeToString; virDomainGraphicsSpiceChannelNameTypeFromString; virDomainGraphicsSpiceChannelNameTypeToString; -virDomainGraphicsSpiceClipboardCopypasteTypeFromString; -virDomainGraphicsSpiceClipboardCopypasteTypeToString; virDomainGraphicsSpiceImageCompressionTypeFromString; virDomainGraphicsSpiceImageCompressionTypeToString; virDomainGraphicsSpiceJpegCompressionTypeFromString; @@ -377,8 +371,6 @@ virDomainPausedReasonTypeFromString; virDomainPausedReasonTypeToString; virDomainPCIRombarModeTypeFromString; virDomainPCIRombarModeTypeToString; -virDomainPMStateTypeFromString; -virDomainPMStateTypeToString; virDomainPMSuspendedReasonTypeFromString; virDomainPMSuspendedReasonTypeToString; virDomainRedirdevBusTypeFromString; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 2185ef4..335a91c 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -6754,9 +6754,9 @@ qemuBuildGraphicsSPICECommandLine(virQEMUDriverConfigPtr cfg, if (graphics->data.spice.streaming) virBufferAsprintf(&opt, ",streaming-video=%s", virDomainGraphicsSpiceStreamingModeTypeToString(graphics->data.spice.streaming)); - if (graphics->data.spice.copypaste == VIR_DOMAIN_GRAPHICS_SPICE_CLIPBOARD_COPYPASTE_NO) + if (graphics->data.spice.copypaste == VIR_DOMAIN_YES_NO_DISABLED) virBufferAddLit(&opt, ",disable-copy-paste"); - if (graphics->data.spice.filetransfer == VIR_DOMAIN_GRAPHICS_SPICE_AGENT_FILE_TRANSFER_NO) { + if (graphics->data.spice.filetransfer == VIR_DOMAIN_YES_NO_DISABLED) { if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_SPICE_FILE_XFER_DISABLE)) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("This QEMU can't disable file transfers through spice")); @@ -7336,7 +7336,7 @@ qemuBuildCommandLine(virConnectPtr conn, } /* Serial graphics adapter */ - if (def->os.bios.useserial == VIR_DOMAIN_BIOS_USESERIAL_YES) { + if (def->os.bios.useserial == VIR_DOMAIN_YES_NO_ENABLED) { if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("qemu does not support -device")); @@ -7555,7 +7555,7 @@ qemuBuildCommandLine(virConnectPtr conn, } virCommandAddArg(cmd, "-global"); virCommandAddArgFormat(cmd, "PIIX4_PM.disable_s3=%d", - def->pm.s3 == VIR_DOMAIN_PM_STATE_DISABLED); + def->pm.s3 == VIR_DOMAIN_YES_NO_DISABLED); } if (def->pm.s4) { @@ -7566,7 +7566,7 @@ qemuBuildCommandLine(virConnectPtr conn, } virCommandAddArg(cmd, "-global"); virCommandAddArgFormat(cmd, "PIIX4_PM.disable_s4=%d", - def->pm.s4 == VIR_DOMAIN_PM_STATE_DISABLED); + def->pm.s4 == VIR_DOMAIN_YES_NO_DISABLED); } if (!def->os.bootloader) { @@ -7588,7 +7588,7 @@ qemuBuildCommandLine(virConnectPtr conn, } emitBootindex = true; } else if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOTINDEX) && - (def->os.bootmenu != VIR_DOMAIN_BOOT_MENU_ENABLED || + (def->os.bootmenu != VIR_DOMAIN_YES_NO_ENABLED || !virQEMUCapsGet(qemuCaps, QEMU_CAPS_BOOT_MENU))) { emitBootindex = true; } @@ -7626,7 +7626,7 @@ qemuBuildCommandLine(virConnectPtr conn, if (boot_nparams++) virBufferAddChar(&boot_buf, ','); - if (def->os.bootmenu == VIR_DOMAIN_BOOT_MENU_ENABLED) + if (def->os.bootmenu == VIR_DOMAIN_YES_NO_ENABLED) virBufferAddLit(&boot_buf, "menu=on"); else virBufferAddLit(&boot_buf, "menu=off"); @@ -11307,9 +11307,9 @@ qemuParseCommandLine(virCapsPtr qemuCaps, val += strlen("PIIX4_PM.disable_s3="); if (STREQ(val, "0")) - def->pm.s3 = VIR_DOMAIN_PM_STATE_ENABLED; + def->pm.s3 = VIR_DOMAIN_YES_NO_ENABLED; else if (STREQ(val, "1")) - def->pm.s3 = VIR_DOMAIN_PM_STATE_DISABLED; + def->pm.s3 = VIR_DOMAIN_YES_NO_DISABLED; else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("invalid value for disable_s3 parameter: " @@ -11324,9 +11324,9 @@ qemuParseCommandLine(virCapsPtr qemuCaps, val += strlen("PIIX4_PM.disable_s4="); if (STREQ(val, "0")) - def->pm.s4 = VIR_DOMAIN_PM_STATE_ENABLED; + def->pm.s4 = VIR_DOMAIN_YES_NO_ENABLED; else if (STREQ(val, "1")) - def->pm.s4 = VIR_DOMAIN_PM_STATE_DISABLED; + def->pm.s4 = VIR_DOMAIN_YES_NO_DISABLED; else { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("invalid value for disable_s4 parameter: " diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index ecccf6c..44aeb3f 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -16236,7 +16236,7 @@ qemuDomainPMSuspendForDuration(virDomainPtr dom, } if (vm->def->pm.s3 || vm->def->pm.s4) { - if (vm->def->pm.s3 == VIR_DOMAIN_PM_STATE_DISABLED && + if (vm->def->pm.s3 == VIR_DOMAIN_YES_NO_DISABLED && (target == VIR_NODE_SUSPEND_TARGET_MEM || target == VIR_NODE_SUSPEND_TARGET_HYBRID)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", @@ -16244,7 +16244,7 @@ qemuDomainPMSuspendForDuration(virDomainPtr dom, goto cleanup; } - if (vm->def->pm.s4 == VIR_DOMAIN_PM_STATE_DISABLED && + if (vm->def->pm.s4 == VIR_DOMAIN_YES_NO_DISABLED && target == VIR_NODE_SUSPEND_TARGET_DISK) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("S4 state is disabled for this domain")); -- 1.8.5.5 -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list