mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 21:55:25 +00:00
virStorageNetHostDef: Convert 'transport' field to proper enum type
Convert the field and adjust the XML parsers to use virXMLPropEnumDefault(). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
2dd6369477
commit
452695926d
@ -5834,17 +5834,13 @@ virDomainStorageNetworkParseHost(xmlNodePtr hostnode,
|
||||
g_autofree char *port = NULL;
|
||||
|
||||
memset(host, 0, sizeof(*host));
|
||||
host->transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
|
||||
|
||||
/* transport can be tcp (default), unix or rdma. */
|
||||
if ((transport = virXMLPropString(hostnode, "transport"))) {
|
||||
host->transport = virStorageNetHostTransportTypeFromString(transport);
|
||||
if (host->transport < 0) {
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("unknown protocol transport type '%1$s'"),
|
||||
transport);
|
||||
goto cleanup;
|
||||
}
|
||||
if (virXMLPropEnumDefault(hostnode, "transport",
|
||||
virStorageNetHostTransportTypeFromString,
|
||||
VIR_XML_PROP_NONE,
|
||||
&host->transport,
|
||||
VIR_STORAGE_NET_HOST_TRANS_TCP) < 0) {
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
host->socket = virXMLPropString(hostnode, "socket");
|
||||
|
@ -151,7 +151,7 @@ typedef struct _virStorageNetHostDef virStorageNetHostDef;
|
||||
struct _virStorageNetHostDef {
|
||||
char *name;
|
||||
unsigned int port;
|
||||
int transport; /* virStorageNetHostTransport */
|
||||
virStorageNetHostTransport transport;
|
||||
char *socket; /* path to unix socket */
|
||||
};
|
||||
|
||||
|
@ -68,7 +68,7 @@ qemuBackupPrepare(virDomainBackupDef *def)
|
||||
def->server->name = g_strdup("localhost");
|
||||
}
|
||||
|
||||
switch ((virStorageNetHostTransport) def->server->transport) {
|
||||
switch (def->server->transport) {
|
||||
case VIR_STORAGE_NET_HOST_TRANS_TCP:
|
||||
/* TODO: Update qemu.conf to provide a port range,
|
||||
* probably starting at 10809, for obtaining automatic
|
||||
|
@ -130,7 +130,7 @@ qemuBlockStorageSourceBuildJSONSocketAddress(virStorageNetHostDef *host)
|
||||
g_autoptr(virJSONValue) server = NULL;
|
||||
g_autofree char *port = NULL;
|
||||
|
||||
switch ((virStorageNetHostTransport) host->transport) {
|
||||
switch (host->transport) {
|
||||
case VIR_STORAGE_NET_HOST_TRANS_TCP:
|
||||
port = g_strdup_printf("%u", host->port);
|
||||
|
||||
|
@ -6176,7 +6176,7 @@ qemuMonitorJSONNBDServerStart(qemuMonitor *mon,
|
||||
g_autoptr(virJSONValue) addr = NULL;
|
||||
g_autofree char *port_str = NULL;
|
||||
|
||||
switch ((virStorageNetHostTransport)server->transport) {
|
||||
switch (server->transport) {
|
||||
case VIR_STORAGE_NET_HOST_TRANS_TCP:
|
||||
port_str = g_strdup_printf("%u", server->port);
|
||||
addr = qemuMonitorJSONBuildInetSocketAddress(server->name, port_str);
|
||||
|
@ -63,7 +63,7 @@ virStorageFileBackendGlusterInitServer(virStorageFileBackendGlusterPriv *priv,
|
||||
const char *hoststr = NULL;
|
||||
int port = 0;
|
||||
|
||||
switch ((virStorageNetHostTransport) host->transport) {
|
||||
switch (host->transport) {
|
||||
case VIR_STORAGE_NET_HOST_TRANS_RDMA:
|
||||
case VIR_STORAGE_NET_HOST_TRANS_TCP:
|
||||
hoststr = host->name;
|
||||
|
@ -42,6 +42,7 @@ virStorageSourceParseBackingURI(virStorageSource *src,
|
||||
{
|
||||
g_autoptr(virURI) uri = NULL;
|
||||
const char *path = NULL;
|
||||
int transport = 0;
|
||||
g_auto(GStrv) scheme = NULL;
|
||||
|
||||
if (!(uri = virURIParse(uristr))) {
|
||||
@ -65,12 +66,14 @@ virStorageSourceParseBackingURI(virStorageSource *src,
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (scheme[1] &&
|
||||
(src->hosts->transport = virStorageNetHostTransportTypeFromString(scheme[1])) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("invalid protocol transport type '%1$s'"),
|
||||
scheme[1]);
|
||||
return -1;
|
||||
if (scheme[1]) {
|
||||
if ((transport = virStorageNetHostTransportTypeFromString(scheme[1])) < 0) {
|
||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||
_("invalid protocol transport type '%1$s'"),
|
||||
scheme[1]);
|
||||
return -1;
|
||||
}
|
||||
src->hosts->transport = transport;
|
||||
}
|
||||
|
||||
if (uri->query) {
|
||||
|
Loading…
Reference in New Issue
Block a user