On 07/16/2014 04:34 AM, Ján Tomko wrote: > Replace all three-state (default/yes/no) enums with it: > virDomainBootMenu > virDomainPMState > virDomainGraphicsSpiceClipboardCopypaste > virDomainGraphicsSpiceAgentFileTransfer > virNetworkDNSForwardPlainNames virDomainBIOSUseserial Too. > --- > src/conf/domain_conf.c | 57 ++++++++++++--------------------------------- > src/conf/domain_conf.h | 43 ---------------------------------- > src/conf/network_conf.c | 11 ++------- > src/conf/network_conf.h | 15 +----------- > src/libvirt_private.syms | 10 ++------ > src/network/bridge_driver.c | 3 +-- > src/qemu/qemu_command.c | 22 ++++++++--------- > src/qemu/qemu_driver.c | 4 ++-- > src/util/virutil.c | 5 ++++ > src/util/virutil.h | 11 +++++++++ > 10 files changed, 50 insertions(+), 131 deletions(-) > > diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c > index 1d83f13..e374604 100644 > --- a/src/conf/domain_conf.c > +++ b/src/conf/domain_conf.c > @@ -134,11 +134,6 @@ VIR_ENUM_IMPL(virDomainBoot, VIR_DOMAIN_BOOT_LAST, > "hd", > "network") > > -VIR_ENUM_IMPL(virDomainBootMenu, VIR_DOMAIN_BOOT_MENU_LAST, > - "default", > - "yes", > - "no") > - > VIR_ENUM_IMPL(virDomainFeature, VIR_DOMAIN_FEATURE_LAST, > "acpi", > "apic", > @@ -180,11 +175,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 +566,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 +8767,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, > } > > if ((copypasteVal = > - virDomainGraphicsSpiceClipboardCopypasteTypeFromString(copypaste)) <= 0) { > + virTristateBoolTypeFromString(copypaste)) <= 0) { > virReportError(VIR_ERR_CONFIG_UNSUPPORTED, > _("unknown copypaste value '%s'"), copypaste); > VIR_FREE(copypaste); > @@ -8809,7 +8787,7 @@ virDomainGraphicsDefParseXML(xmlNodePtr node, > } > > if ((enableVal = > - virDomainGraphicsSpiceAgentFileTransferTypeFromString(enable)) <= 0) { > + virTristateBoolTypeFromString(enable)) <= 0) { > virReportError(VIR_ERR_CONFIG_UNSUPPORTED, > _("unknown enable value '%s'"), enable); > VIR_FREE(enable); > @@ -9916,7 +9894,7 @@ virDomainPMStateParseXML(xmlXPathContextPtr ctxt, > int ret = -1; > char *tmp = virXPathString(xpath, ctxt); > if (tmp) { > - *val = virDomainPMStateTypeFromString(tmp); > + *val = virTristateBoolTypeFromString(tmp); > if (*val < 0) { > virReportError(VIR_ERR_CONFIG_UNSUPPORTED, > _("unknown PM state value %s"), tmp); > @@ -10879,14 +10857,14 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, > > tmp = virXPathString("string(./os/bootmenu[1]/@enable)", ctxt); > if (tmp) { > - def->os.bootmenu = virDomainBootMenuTypeFromString(tmp); > + def->os.bootmenu = virTristateBoolTypeFromString(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_TRISTATE_BOOL_NO; > } > VIR_FREE(tmp); > } > @@ -10901,9 +10879,9 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, > "for useserial")); > goto cleanup; > } > - def->os.bios.useserial = VIR_DOMAIN_BIOS_USESERIAL_YES; > + def->os.bios.useserial = VIR_TRISTATE_BOOL_YES; > } else { > - def->os.bios.useserial = VIR_DOMAIN_BIOS_USESERIAL_NO; > + def->os.bios.useserial = VIR_TRISTATE_BOOL_NO; > } > VIR_FREE(tmp); > } > @@ -16943,10 +16921,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)); > + virTristateBoolTypeToString(def->data.spice.copypaste)); > if (def->data.spice.filetransfer) > virBufferAsprintf(buf, "<filetransfer enable='%s'/>\n", > - virDomainGraphicsSpiceAgentFileTransferTypeToString(def->data.spice.filetransfer)); > + virTristateBoolTypeToString(def->data.spice.filetransfer)); > } > > if (children) { > @@ -17528,20 +17506,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", > + virTristateBoolTypeToString(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")); > + virTristateBoolTypeToString(def->os.bios.useserial)); > if (def->os.bios.rt_set) > virBufferAsprintf(buf, " rebootTimeout='%d'", def->os.bios.rt_delay); > > @@ -17766,11 +17739,11 @@ virDomainDefFormatInternal(virDomainDefPtr def, > virBufferAdjustIndent(buf, 2); > if (def->pm.s3) { > virBufferAsprintf(buf, "<suspend-to-mem enabled='%s'/>\n", > - virDomainPMStateTypeToString(def->pm.s3)); > + virTristateBoolTypeToString(def->pm.s3)); > } > if (def->pm.s4) { > virBufferAsprintf(buf, "<suspend-to-disk enabled='%s'/>\n", > - virDomainPMStateTypeToString(def->pm.s4)); > + virTristateBoolTypeToString(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..8d2c546 100644 > --- a/src/conf/domain_conf.h > +++ b/src/conf/domain_conf.h Some comments for enum usage that need to be adjusted to use the Tristate (I used cscope and search on egrep)... struct _virDomainOSDef { ... int bootDevs[VIR_DOMAIN_BOOT_LAST]; /* enum virDomainBootMenu */ int bootmenu; ... struct _virDomainDef { ... struct { /* These options are actually type of enum virDomainPMState */ int s3; int s4; } pm; ... I didn't check that the Tristate comment was used in all the new target fields... > @@ -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,14 +1496,6 @@ typedef enum { > } virDomainBootOrder; > > typedef enum { > - VIR_DOMAIN_BOOT_MENU_DEFAULT = 0, > - VIR_DOMAIN_BOOT_MENU_ENABLED, > - VIR_DOMAIN_BOOT_MENU_DISABLED, > - > - VIR_DOMAIN_BOOT_MENU_LAST > -} virDomainBootMenu; > - > -typedef enum { > VIR_DOMAIN_FEATURE_ACPI, > VIR_DOMAIN_FEATURE_APIC, > VIR_DOMAIN_FEATURE_PAE, > @@ -1580,20 +1556,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 { > @@ -2528,15 +2490,12 @@ typedef const char* (*virEventActionToStringFunc)(int type); > typedef int (*virEventActionFromStringFunc)(const char *type); > > VIR_ENUM_DECL(virDomainTaint) > - > VIR_ENUM_DECL(virDomainVirt) > VIR_ENUM_DECL(virDomainBoot) > -VIR_ENUM_DECL(virDomainBootMenu) > 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 +2549,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 +2556,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/conf/network_conf.c b/src/conf/network_conf.c > index ce4d4d8..43d2f60 100644 > --- a/src/conf/network_conf.c > +++ b/src/conf/network_conf.c > @@ -66,12 +66,6 @@ VIR_ENUM_IMPL(virNetworkForwardDriverName, > "kvm", > "vfio") > > -VIR_ENUM_IMPL(virNetworkDNSForwardPlainNames, > - VIR_NETWORK_DNS_FORWARD_PLAIN_NAMES_LAST, > - "default", > - "yes", > - "no") > - > VIR_ENUM_IMPL(virNetworkTaint, VIR_NETWORK_TAINT_LAST, > "hook-script"); > > @@ -1123,8 +1117,7 @@ virNetworkDNSDefParseXML(const char *networkName, > [1] See comment just below > forwardPlainNames = virXPathString("string(./@forwardPlainNames)", ctxt); > if (forwardPlainNames) { > - def->forwardPlainNames > - = virNetworkDNSForwardPlainNamesTypeFromString(forwardPlainNames); > + def->forwardPlainNames = virTristateBoolTypeFromString(forwardPlainNames); > if (def->forwardPlainNames <= 0) { > virReportError(VIR_ERR_XML_ERROR, > _("Invalid dns forwardPlainNames setting '%s' " > @@ -2373,7 +2366,7 @@ virNetworkDNSDefFormat(virBufferPtr buf, > > virBufferAddLit(buf, "<dns"); > if (def->forwardPlainNames) { > - const char *fwd = virNetworkDNSForwardPlainNamesTypeToString(def->forwardPlainNames); > + const char *fwd = virTristateBoolTypeToString(def->forwardPlainNames); > > if (!fwd) { > virReportError(VIR_ERR_INTERNAL_ERROR, > diff --git a/src/conf/network_conf.h b/src/conf/network_conf.h > index c4e9d92..7ed58cd 100644 > --- a/src/conf/network_conf.h > +++ b/src/conf/network_conf.h > @@ -112,23 +112,10 @@ struct _virNetworkDNSHostDef { > char **names; > }; > > -/* If forwardPlainNames is 0 (default), that is equivalent to "yes", > - * but won't be encoded in newly formatted XML. > - */ While this concept is carried through in networkDnsmasqConfContents() - one wonders if someone, someday will come along and "only check" for just YES and not include DEFAULT as well... It's one of those "hidden" things that perhaps to be "safe" you should copy this comment over into virNetworkDNSDefFormat()... Your call on how to handle. ACK with comment issues resolved. John > -typedef enum { > - VIR_NETWORK_DNS_FORWARD_PLAIN_NAMES_DEFAULT = 0, /* silent "yes" */ > - VIR_NETWORK_DNS_FORWARD_PLAIN_NAMES_YES, > - VIR_NETWORK_DNS_FORWARD_PLAIN_NAMES_NO, > - > - VIR_NETWORK_DNS_FORWARD_PLAIN_NAMES_LAST, > -} virNetworkDNSForwardPlainNamesType; > - > -VIR_ENUM_DECL(virNetworkDNSForwardPlainNames) > - > typedef struct _virNetworkDNSDef virNetworkDNSDef; > typedef virNetworkDNSDef *virNetworkDNSDefPtr; > struct _virNetworkDNSDef { > - int forwardPlainNames; /* enum virNetworkDNSForwardPlainNamesType */ > + int forwardPlainNames; /* enum virTristateBool */ > size_t ntxts; > virNetworkDNSTxtDefPtr txts; > size_t nhosts; > diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms > index a184268..5e73f51 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; > @@ -2138,6 +2130,8 @@ virSetSockReuseAddr; > virSetUIDGID; > virSetUIDGIDWithCaps; > virStrIsPrint; > +virTristateBoolTypeFromString; > +virTristateBoolTypeToString; > virUpdateSelfLastChanged; > virValidateWWN; > > diff --git a/src/network/bridge_driver.c b/src/network/bridge_driver.c > index 6a2e760..6ccc6e2 100644 > --- a/src/network/bridge_driver.c > +++ b/src/network/bridge_driver.c > @@ -927,8 +927,7 @@ networkDnsmasqConfContents(virNetworkObjPtr network, > network->def->domain); > } > > - if (network->def->dns.forwardPlainNames > - == VIR_NETWORK_DNS_FORWARD_PLAIN_NAMES_NO) { > + if (network->def->dns.forwardPlainNames == VIR_TRISTATE_BOOL_NO) { > virBufferAddLit(&configbuf, "domain-needed\n"); > /* need to specify local=// whether or not a domain is > * specified, unless the config says we should forward "plain" > diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c > index 2185ef4..bde3af1 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_TRISTATE_BOOL_NO) > virBufferAddLit(&opt, ",disable-copy-paste"); > - if (graphics->data.spice.filetransfer == VIR_DOMAIN_GRAPHICS_SPICE_AGENT_FILE_TRANSFER_NO) { > + if (graphics->data.spice.filetransfer == VIR_TRISTATE_BOOL_NO) { > 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_TRISTATE_BOOL_YES) { > 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_TRISTATE_BOOL_NO); > } > > 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_TRISTATE_BOOL_NO); > } > > 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_TRISTATE_BOOL_YES || > !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_TRISTATE_BOOL_YES) > 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_TRISTATE_BOOL_YES; > else if (STREQ(val, "1")) > - def->pm.s3 = VIR_DOMAIN_PM_STATE_DISABLED; > + def->pm.s3 = VIR_TRISTATE_BOOL_NO; > 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_TRISTATE_BOOL_YES; > else if (STREQ(val, "1")) > - def->pm.s4 = VIR_DOMAIN_PM_STATE_DISABLED; > + def->pm.s4 = VIR_TRISTATE_BOOL_NO; > 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 62b7f07..46ab766 100644 > --- a/src/qemu/qemu_driver.c > +++ b/src/qemu/qemu_driver.c > @@ -16225,7 +16225,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_TRISTATE_BOOL_NO && > (target == VIR_NODE_SUSPEND_TARGET_MEM || > target == VIR_NODE_SUSPEND_TARGET_HYBRID)) { > virReportError(VIR_ERR_INTERNAL_ERROR, "%s", > @@ -16233,7 +16233,7 @@ qemuDomainPMSuspendForDuration(virDomainPtr dom, > goto cleanup; > } > > - if (vm->def->pm.s4 == VIR_DOMAIN_PM_STATE_DISABLED && > + if (vm->def->pm.s4 == VIR_TRISTATE_BOOL_NO && > target == VIR_NODE_SUSPEND_TARGET_DISK) { > virReportError(VIR_ERR_INTERNAL_ERROR, "%s", > _("S4 state is disabled for this domain")); > diff --git a/src/util/virutil.c b/src/util/virutil.c > index 95d1ff9..305c40c 100644 > --- a/src/util/virutil.c > +++ b/src/util/virutil.c > @@ -92,6 +92,11 @@ verify(sizeof(gid_t) <= sizeof(unsigned int) && > > VIR_LOG_INIT("util.util"); > > +VIR_ENUM_IMPL(virTristateBool, VIR_TRISTATE_BOOL_LAST, > + "default", > + "yes", > + "no") > + > #ifndef WIN32 > > int virSetInherit(int fd, bool inherit) > diff --git a/src/util/virutil.h b/src/util/virutil.h > index 2bb74e2..a06b9a5 100644 > --- a/src/util/virutil.h > +++ b/src/util/virutil.h > @@ -38,6 +38,7 @@ > # define MAX(a, b) ((a) > (b) ? (a) : (b)) > # endif > > + > int virSetBlocking(int fd, bool blocking) ATTRIBUTE_RETURN_CHECK; > int virSetNonBlock(int fd) ATTRIBUTE_RETURN_CHECK; > int virSetInherit(int fd, bool inherit) ATTRIBUTE_RETURN_CHECK; > @@ -203,4 +204,14 @@ bool virIsSUID(void); > time_t virGetSelfLastChanged(void); > void virUpdateSelfLastChanged(const char *path); > > +typedef enum { > + VIR_TRISTATE_BOOL_ABSENT = 0, > + VIR_TRISTATE_BOOL_YES, > + VIR_TRISTATE_BOOL_NO, > + > + VIR_TRISTATE_BOOL_LAST > +} virTristateBool; > + > +VIR_ENUM_DECL(virTristateBool) > + > #endif /* __VIR_UTIL_H__ */ > -- libvir-list mailing list libvir-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/libvir-list