conf: Use virTristateXXX in virDomainChrSourceDef

Signed-off-by: Tim Wiederhake <twiederh@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
This commit is contained in:
Tim Wiederhake 2021-04-07 13:48:34 +02:00 committed by Peter Krempa
parent 6609b64701
commit b96527751f
2 changed files with 24 additions and 16 deletions

View File

@ -11913,12 +11913,14 @@ virDomainChrSourceDefParseTCP(virDomainChrSourceDef *def,
def->data.tcp.service = virXMLPropString(source, "service"); def->data.tcp.service = virXMLPropString(source, "service");
if ((tmp = virXMLPropString(source, "tls"))) { if ((tmp = virXMLPropString(source, "tls"))) {
if ((def->data.tcp.haveTLS = virTristateBoolTypeFromString(tmp)) <= 0) { int value;
if ((value = virTristateBoolTypeFromString(tmp)) <= 0) {
virReportError(VIR_ERR_XML_ERROR, virReportError(VIR_ERR_XML_ERROR,
_("unknown chardev 'tls' setting '%s'"), _("unknown chardev 'tls' setting '%s'"),
tmp); tmp);
return -1; return -1;
} }
def->data.tcp.haveTLS = value;
VIR_FREE(tmp); VIR_FREE(tmp);
} }
@ -11997,12 +11999,15 @@ virDomainChrSourceDefParseFile(virDomainChrSourceDef *def,
def->data.file.path = virXMLPropString(source, "path"); def->data.file.path = virXMLPropString(source, "path");
if ((append = virXMLPropString(source, "append")) && if ((append = virXMLPropString(source, "append"))) {
(def->data.file.append = virTristateSwitchTypeFromString(append)) <= 0) { int value;
virReportError(VIR_ERR_INTERNAL_ERROR, if ((value = virTristateSwitchTypeFromString(append)) <= 0) {
_("Invalid append attribute value '%s'"), virReportError(VIR_ERR_INTERNAL_ERROR,
append); _("Invalid append attribute value '%s'"),
return -1; append);
return -1;
}
def->data.file.append = value;
} }
return 0; return 0;
@ -12038,12 +12043,15 @@ virDomainChrSourceDefParseLog(virDomainChrSourceDef *def,
def->logfile = virXMLPropString(log, "file"); def->logfile = virXMLPropString(log, "file");
if ((append = virXMLPropString(log, "append")) && if ((append = virXMLPropString(log, "append"))) {
(def->logappend = virTristateSwitchTypeFromString(append)) <= 0) { int value;
virReportError(VIR_ERR_INTERNAL_ERROR, if ((value = virTristateSwitchTypeFromString(append)) <= 0) {
_("Invalid append attribute value '%s'"), virReportError(VIR_ERR_INTERNAL_ERROR,
append); _("Invalid append attribute value '%s'"),
return -1; append);
return -1;
}
def->logappend = value;
} }
return 0; return 0;

View File

@ -1233,7 +1233,7 @@ struct _virDomainChrSourceDef {
/* no <source> for null, vc, stdio */ /* no <source> for null, vc, stdio */
struct { struct {
char *path; char *path;
int append; /* enum virTristateSwitch */ virTristateSwitch append;
} file; /* pty, file, pipe, or device */ } file; /* pty, file, pipe, or device */
struct { struct {
char *master; char *master;
@ -1245,7 +1245,7 @@ struct _virDomainChrSourceDef {
bool listen; bool listen;
int protocol; int protocol;
bool tlscreds; bool tlscreds;
int haveTLS; /* enum virTristateBool */ virTristateBool haveTLS;
bool tlsFromConfig; bool tlsFromConfig;
virDomainChrSourceReconnectDef reconnect; virDomainChrSourceReconnectDef reconnect;
} tcp; } tcp;
@ -1266,7 +1266,7 @@ struct _virDomainChrSourceDef {
} spiceport; } spiceport;
} data; } data;
char *logfile; char *logfile;
int logappend; virTristateSwitch logappend;
size_t nseclabels; size_t nseclabels;
virSecurityDeviceLabelDef **seclabels; virSecurityDeviceLabelDef **seclabels;