1
0
mirror of https://gitlab.com/libvirt/libvirt.git synced 2024-12-27 07:22:07 +03:00

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

View File

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