mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-07 18:35:46 +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;
|
g_autofree char *port = NULL;
|
||||||
|
|
||||||
memset(host, 0, sizeof(*host));
|
memset(host, 0, sizeof(*host));
|
||||||
host->transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
|
|
||||||
|
|
||||||
/* transport can be tcp (default), unix or rdma. */
|
if (virXMLPropEnumDefault(hostnode, "transport",
|
||||||
if ((transport = virXMLPropString(hostnode, "transport"))) {
|
virStorageNetHostTransportTypeFromString,
|
||||||
host->transport = virStorageNetHostTransportTypeFromString(transport);
|
VIR_XML_PROP_NONE,
|
||||||
if (host->transport < 0) {
|
&host->transport,
|
||||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
VIR_STORAGE_NET_HOST_TRANS_TCP) < 0) {
|
||||||
_("unknown protocol transport type '%1$s'"),
|
goto cleanup;
|
||||||
transport);
|
|
||||||
goto cleanup;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
host->socket = virXMLPropString(hostnode, "socket");
|
host->socket = virXMLPropString(hostnode, "socket");
|
||||||
|
@ -151,7 +151,7 @@ typedef struct _virStorageNetHostDef virStorageNetHostDef;
|
|||||||
struct _virStorageNetHostDef {
|
struct _virStorageNetHostDef {
|
||||||
char *name;
|
char *name;
|
||||||
unsigned int port;
|
unsigned int port;
|
||||||
int transport; /* virStorageNetHostTransport */
|
virStorageNetHostTransport transport;
|
||||||
char *socket; /* path to unix socket */
|
char *socket; /* path to unix socket */
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ qemuBackupPrepare(virDomainBackupDef *def)
|
|||||||
def->server->name = g_strdup("localhost");
|
def->server->name = g_strdup("localhost");
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ((virStorageNetHostTransport) def->server->transport) {
|
switch (def->server->transport) {
|
||||||
case VIR_STORAGE_NET_HOST_TRANS_TCP:
|
case VIR_STORAGE_NET_HOST_TRANS_TCP:
|
||||||
/* TODO: Update qemu.conf to provide a port range,
|
/* TODO: Update qemu.conf to provide a port range,
|
||||||
* probably starting at 10809, for obtaining automatic
|
* probably starting at 10809, for obtaining automatic
|
||||||
|
@ -130,7 +130,7 @@ qemuBlockStorageSourceBuildJSONSocketAddress(virStorageNetHostDef *host)
|
|||||||
g_autoptr(virJSONValue) server = NULL;
|
g_autoptr(virJSONValue) server = NULL;
|
||||||
g_autofree char *port = NULL;
|
g_autofree char *port = NULL;
|
||||||
|
|
||||||
switch ((virStorageNetHostTransport) host->transport) {
|
switch (host->transport) {
|
||||||
case VIR_STORAGE_NET_HOST_TRANS_TCP:
|
case VIR_STORAGE_NET_HOST_TRANS_TCP:
|
||||||
port = g_strdup_printf("%u", host->port);
|
port = g_strdup_printf("%u", host->port);
|
||||||
|
|
||||||
|
@ -6176,7 +6176,7 @@ qemuMonitorJSONNBDServerStart(qemuMonitor *mon,
|
|||||||
g_autoptr(virJSONValue) addr = NULL;
|
g_autoptr(virJSONValue) addr = NULL;
|
||||||
g_autofree char *port_str = NULL;
|
g_autofree char *port_str = NULL;
|
||||||
|
|
||||||
switch ((virStorageNetHostTransport)server->transport) {
|
switch (server->transport) {
|
||||||
case VIR_STORAGE_NET_HOST_TRANS_TCP:
|
case VIR_STORAGE_NET_HOST_TRANS_TCP:
|
||||||
port_str = g_strdup_printf("%u", server->port);
|
port_str = g_strdup_printf("%u", server->port);
|
||||||
addr = qemuMonitorJSONBuildInetSocketAddress(server->name, port_str);
|
addr = qemuMonitorJSONBuildInetSocketAddress(server->name, port_str);
|
||||||
|
@ -63,7 +63,7 @@ virStorageFileBackendGlusterInitServer(virStorageFileBackendGlusterPriv *priv,
|
|||||||
const char *hoststr = NULL;
|
const char *hoststr = NULL;
|
||||||
int port = 0;
|
int port = 0;
|
||||||
|
|
||||||
switch ((virStorageNetHostTransport) host->transport) {
|
switch (host->transport) {
|
||||||
case VIR_STORAGE_NET_HOST_TRANS_RDMA:
|
case VIR_STORAGE_NET_HOST_TRANS_RDMA:
|
||||||
case VIR_STORAGE_NET_HOST_TRANS_TCP:
|
case VIR_STORAGE_NET_HOST_TRANS_TCP:
|
||||||
hoststr = host->name;
|
hoststr = host->name;
|
||||||
|
@ -42,6 +42,7 @@ virStorageSourceParseBackingURI(virStorageSource *src,
|
|||||||
{
|
{
|
||||||
g_autoptr(virURI) uri = NULL;
|
g_autoptr(virURI) uri = NULL;
|
||||||
const char *path = NULL;
|
const char *path = NULL;
|
||||||
|
int transport = 0;
|
||||||
g_auto(GStrv) scheme = NULL;
|
g_auto(GStrv) scheme = NULL;
|
||||||
|
|
||||||
if (!(uri = virURIParse(uristr))) {
|
if (!(uri = virURIParse(uristr))) {
|
||||||
@ -65,12 +66,14 @@ virStorageSourceParseBackingURI(virStorageSource *src,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (scheme[1] &&
|
if (scheme[1]) {
|
||||||
(src->hosts->transport = virStorageNetHostTransportTypeFromString(scheme[1])) < 0) {
|
if ((transport = virStorageNetHostTransportTypeFromString(scheme[1])) < 0) {
|
||||||
virReportError(VIR_ERR_INTERNAL_ERROR,
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
_("invalid protocol transport type '%1$s'"),
|
_("invalid protocol transport type '%1$s'"),
|
||||||
scheme[1]);
|
scheme[1]);
|
||||||
return -1;
|
return -1;
|
||||||
|
}
|
||||||
|
src->hosts->transport = transport;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uri->query) {
|
if (uri->query) {
|
||||||
|
Loading…
Reference in New Issue
Block a user