提交 52fb5311 编写于 作者: E Eric Blake

conf: split network host structs to util/

Continuing the refactoring of host-side storage descriptions out
of conf/domain_conf and into util/virstoragefile, this patch
focuses on details about a host name/port/transport as used by
a network storage volume.

* src/conf/domain_conf.h (virDomainDiskProtocolTransport)
(virDomainDiskHostDef, virDomainDiskHostDefClear)
(virDomainDiskHostDefFree, virDomainDiskHostDefCopy): Move...
* src/util/virstoragefile.h (virStorageNetHostTransport)
(virStorageNetHostDef, virStorageNetHostDefClear)
(virStorageNetHostDefFree, virStorageNetHostDefCopy): ...here,
with better names.
* src/util/virstoragefile.c (virStorageNetHostDefClear)
(virStorageNetHostDefFree, virStorageNetHostDefCopy): Moved from...
* src/conf/domain_conf.c (virDomainDiskHostDefClear)
(virDomainDiskHostDefFree, virDomainDiskHostDefCopy): ...here.
(virDomainDiskSourceDefClear, virDomainDiskSourceDefParse)
(virDomainDiskSourceDefFormatInternal): Adjust callers.
* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Likewise.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefClear):
Likewise.
* src/qemu/qemu_command.c (qemuAddRBDHost)
(qemuParseDriveURIString, qemuParseNBDString)
(qemuBuildNetworkDriveURI, qemuParseCommandLineDisk)
(qemuParseCommandLine, qemuGetDriveSourceString): Likewise.
* src/qemu/qemu_command.h: Likewise.
* src/qemu/qemu_conf.c (qemuAddISCSIPoolSourceHost)
(qemuTranslateDiskSourcePool): Likewise.
* src/qemu/qemu_driver.c
(qemuDomainSnapshotCreateSingleDiskActive)
(qemuDomainSnapshotUndoSingleDiskActive): Likewise.
* src/storage/storage_backend_gluster.c
(virStorageFileBackendGlusterInit): Likewise.
* src/storage/storage_driver.c (virStorageFileFree)
(virStorageFileInitInternal): Likewise.
* src/storage/storage_driver.h (_virStorageFile): Likewise.
* src/libvirt_private.syms (domain_conf.h): Move symbols...
(virstoragefile.h): ...as appropriate.
Signed-off-by: NEric Blake <eblake@redhat.com>
上级 3e929386
...@@ -276,11 +276,6 @@ VIR_ENUM_IMPL(virDomainDiskProtocol, VIR_DOMAIN_DISK_PROTOCOL_LAST, ...@@ -276,11 +276,6 @@ VIR_ENUM_IMPL(virDomainDiskProtocol, VIR_DOMAIN_DISK_PROTOCOL_LAST,
"ftps", "ftps",
"tftp") "tftp")
VIR_ENUM_IMPL(virDomainDiskProtocolTransport, VIR_DOMAIN_DISK_PROTO_TRANS_LAST,
"tcp",
"unix",
"rdma")
VIR_ENUM_IMPL(virDomainDiskSecretType, VIR_DOMAIN_DISK_SECRET_TYPE_LAST, VIR_ENUM_IMPL(virDomainDiskSecretType, VIR_DOMAIN_DISK_SECRET_TYPE_LAST,
"none", "none",
"uuid", "uuid",
...@@ -1245,7 +1240,7 @@ virDomainDiskSourceDefClear(virDomainDiskSourceDefPtr def) ...@@ -1245,7 +1240,7 @@ virDomainDiskSourceDefClear(virDomainDiskSourceDefPtr def)
VIR_FREE(def->seclabels); VIR_FREE(def->seclabels);
} }
virDomainDiskHostDefFree(def->nhosts, def->hosts); virStorageNetHostDefFree(def->nhosts, def->hosts);
virDomainDiskAuthClear(def); virDomainDiskAuthClear(def);
} }
...@@ -1282,67 +1277,6 @@ virDomainDiskAuthClear(virDomainDiskSourceDefPtr def) ...@@ -1282,67 +1277,6 @@ virDomainDiskAuthClear(virDomainDiskSourceDefPtr def)
} }
void virDomainDiskHostDefClear(virDomainDiskHostDefPtr def)
{
if (!def)
return;
VIR_FREE(def->name);
VIR_FREE(def->port);
VIR_FREE(def->socket);
}
void
virDomainDiskHostDefFree(size_t nhosts,
virDomainDiskHostDefPtr hosts)
{
size_t i;
if (!hosts)
return;
for (i = 0; i < nhosts; i++)
virDomainDiskHostDefClear(&hosts[i]);
VIR_FREE(hosts);
}
virDomainDiskHostDefPtr
virDomainDiskHostDefCopy(size_t nhosts,
virDomainDiskHostDefPtr hosts)
{
virDomainDiskHostDefPtr ret = NULL;
size_t i;
if (VIR_ALLOC_N(ret, nhosts) < 0)
goto error;
for (i = 0; i < nhosts; i++) {
virDomainDiskHostDefPtr src = &hosts[i];
virDomainDiskHostDefPtr dst = &ret[i];
dst->transport = src->transport;
if (VIR_STRDUP(dst->name, src->name) < 0)
goto error;
if (VIR_STRDUP(dst->port, src->port) < 0)
goto error;
if (VIR_STRDUP(dst->socket, src->socket) < 0)
goto error;
}
return ret;
error:
virDomainDiskHostDefFree(nhosts, ret);
return NULL;
}
int int
virDomainDiskGetType(virDomainDiskDefPtr def) virDomainDiskGetType(virDomainDiskDefPtr def)
{ {
...@@ -5102,12 +5036,12 @@ virDomainDiskSourceDefParse(xmlNodePtr node, ...@@ -5102,12 +5036,12 @@ virDomainDiskSourceDefParse(xmlNodePtr node,
char **source, char **source,
int *proto, int *proto,
size_t *nhosts, size_t *nhosts,
virDomainDiskHostDefPtr *hosts, virStorageNetHostDefPtr *hosts,
virDomainDiskSourcePoolDefPtr *srcpool) virDomainDiskSourcePoolDefPtr *srcpool)
{ {
char *protocol = NULL; char *protocol = NULL;
char *transport = NULL; char *transport = NULL;
virDomainDiskHostDef host; virStorageNetHostDef host;
xmlNodePtr child; xmlNodePtr child;
int ret = -1; int ret = -1;
...@@ -5148,11 +5082,11 @@ virDomainDiskSourceDefParse(xmlNodePtr node, ...@@ -5148,11 +5082,11 @@ virDomainDiskSourceDefParse(xmlNodePtr node,
if (child->type == XML_ELEMENT_NODE && if (child->type == XML_ELEMENT_NODE &&
xmlStrEqual(child->name, BAD_CAST "host")) { xmlStrEqual(child->name, BAD_CAST "host")) {
host.transport = VIR_DOMAIN_DISK_PROTO_TRANS_TCP; host.transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
/* transport can be tcp (default), unix or rdma. */ /* transport can be tcp (default), unix or rdma. */
if ((transport = virXMLPropString(child, "transport"))) { if ((transport = virXMLPropString(child, "transport"))) {
host.transport = virDomainDiskProtocolTransportTypeFromString(transport); host.transport = virStorageNetHostTransportTypeFromString(transport);
if (host.transport < 0) { if (host.transport < 0) {
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("unknown protocol transport type '%s'"), _("unknown protocol transport type '%s'"),
...@@ -5163,14 +5097,14 @@ virDomainDiskSourceDefParse(xmlNodePtr node, ...@@ -5163,14 +5097,14 @@ virDomainDiskSourceDefParse(xmlNodePtr node,
host.socket = virXMLPropString(child, "socket"); host.socket = virXMLPropString(child, "socket");
if (host.transport == VIR_DOMAIN_DISK_PROTO_TRANS_UNIX && if (host.transport == VIR_STORAGE_NET_HOST_TRANS_UNIX &&
host.socket == NULL) { host.socket == NULL) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("missing socket for unix transport")); _("missing socket for unix transport"));
goto cleanup; goto cleanup;
} }
if (host.transport != VIR_DOMAIN_DISK_PROTO_TRANS_UNIX && if (host.transport != VIR_STORAGE_NET_HOST_TRANS_UNIX &&
host.socket != NULL) { host.socket != NULL) {
virReportError(VIR_ERR_XML_ERROR, virReportError(VIR_ERR_XML_ERROR,
_("transport '%s' does not support " _("transport '%s' does not support "
...@@ -5181,7 +5115,7 @@ virDomainDiskSourceDefParse(xmlNodePtr node, ...@@ -5181,7 +5115,7 @@ virDomainDiskSourceDefParse(xmlNodePtr node,
VIR_FREE(transport); VIR_FREE(transport);
if (host.transport != VIR_DOMAIN_DISK_PROTO_TRANS_UNIX) { if (host.transport != VIR_STORAGE_NET_HOST_TRANS_UNIX) {
if (!(host.name = virXMLPropString(child, "name"))) { if (!(host.name = virXMLPropString(child, "name"))) {
virReportError(VIR_ERR_XML_ERROR, "%s", virReportError(VIR_ERR_XML_ERROR, "%s",
_("missing name for host")); _("missing name for host"));
...@@ -5217,7 +5151,7 @@ virDomainDiskSourceDefParse(xmlNodePtr node, ...@@ -5217,7 +5151,7 @@ virDomainDiskSourceDefParse(xmlNodePtr node,
ret = 0; ret = 0;
cleanup: cleanup:
virDomainDiskHostDefClear(&host); virStorageNetHostDefClear(&host);
VIR_FREE(protocol); VIR_FREE(protocol);
VIR_FREE(transport); VIR_FREE(transport);
return ret; return ret;
...@@ -14843,7 +14777,7 @@ virDomainDiskSourceDefFormatInternal(virBufferPtr buf, ...@@ -14843,7 +14777,7 @@ virDomainDiskSourceDefFormatInternal(virBufferPtr buf,
int policy, int policy,
int protocol, int protocol,
size_t nhosts, size_t nhosts,
virDomainDiskHostDefPtr hosts, virStorageNetHostDefPtr hosts,
size_t nseclabels, size_t nseclabels,
virSecurityDeviceLabelDefPtr *seclabels, virSecurityDeviceLabelDefPtr *seclabels,
virDomainDiskSourcePoolDefPtr srcpool, virDomainDiskSourcePoolDefPtr srcpool,
...@@ -14897,7 +14831,7 @@ virDomainDiskSourceDefFormatInternal(virBufferPtr buf, ...@@ -14897,7 +14831,7 @@ virDomainDiskSourceDefFormatInternal(virBufferPtr buf,
if (hosts[n].transport) if (hosts[n].transport)
virBufferAsprintf(buf, " transport='%s'", virBufferAsprintf(buf, " transport='%s'",
virDomainDiskProtocolTransportTypeToString(hosts[n].transport)); virStorageNetHostTransportTypeToString(hosts[n].transport));
virBufferEscapeString(buf, " socket='%s'", hosts[n].socket); virBufferEscapeString(buf, " socket='%s'", hosts[n].socket);
......
...@@ -533,14 +533,6 @@ enum virDomainDiskProtocol { ...@@ -533,14 +533,6 @@ enum virDomainDiskProtocol {
VIR_DOMAIN_DISK_PROTOCOL_LAST VIR_DOMAIN_DISK_PROTOCOL_LAST
}; };
enum virDomainDiskProtocolTransport {
VIR_DOMAIN_DISK_PROTO_TRANS_TCP,
VIR_DOMAIN_DISK_PROTO_TRANS_UNIX,
VIR_DOMAIN_DISK_PROTO_TRANS_RDMA,
VIR_DOMAIN_DISK_PROTO_TRANS_LAST
};
enum virDomainDiskTray { enum virDomainDiskTray {
VIR_DOMAIN_DISK_TRAY_CLOSED, VIR_DOMAIN_DISK_TRAY_CLOSED,
VIR_DOMAIN_DISK_TRAY_OPEN, VIR_DOMAIN_DISK_TRAY_OPEN,
...@@ -557,15 +549,6 @@ enum virDomainDiskGeometryTrans { ...@@ -557,15 +549,6 @@ enum virDomainDiskGeometryTrans {
VIR_DOMAIN_DISK_TRANS_LAST VIR_DOMAIN_DISK_TRANS_LAST
}; };
typedef struct _virDomainDiskHostDef virDomainDiskHostDef;
typedef virDomainDiskHostDef *virDomainDiskHostDefPtr;
struct _virDomainDiskHostDef {
char *name;
char *port;
int transport; /* enum virDomainDiskProtocolTransport */
char *socket; /* path to unix socket */
};
enum virDomainDiskIo { enum virDomainDiskIo {
VIR_DOMAIN_DISK_IO_DEFAULT, VIR_DOMAIN_DISK_IO_DEFAULT,
VIR_DOMAIN_DISK_IO_NATIVE, VIR_DOMAIN_DISK_IO_NATIVE,
...@@ -684,7 +667,7 @@ struct _virDomainDiskSourceDef { ...@@ -684,7 +667,7 @@ struct _virDomainDiskSourceDef {
char *path; char *path;
int protocol; /* enum virDomainDiskProtocol */ int protocol; /* enum virDomainDiskProtocol */
size_t nhosts; size_t nhosts;
virDomainDiskHostDefPtr hosts; virStorageNetHostDefPtr hosts;
virDomainDiskSourcePoolDefPtr srcpool; virDomainDiskSourcePoolDefPtr srcpool;
struct { struct {
char *username; char *username;
...@@ -2232,10 +2215,6 @@ void virDomainInputDefFree(virDomainInputDefPtr def); ...@@ -2232,10 +2215,6 @@ void virDomainInputDefFree(virDomainInputDefPtr def);
void virDomainDiskDefFree(virDomainDiskDefPtr def); void virDomainDiskDefFree(virDomainDiskDefPtr def);
void virDomainLeaseDefFree(virDomainLeaseDefPtr def); void virDomainLeaseDefFree(virDomainLeaseDefPtr def);
void virDomainDiskAuthClear(virDomainDiskSourceDefPtr def); void virDomainDiskAuthClear(virDomainDiskSourceDefPtr def);
void virDomainDiskHostDefClear(virDomainDiskHostDefPtr def);
void virDomainDiskHostDefFree(size_t nhosts, virDomainDiskHostDefPtr hosts);
virDomainDiskHostDefPtr virDomainDiskHostDefCopy(size_t nhosts,
virDomainDiskHostDefPtr hosts);
int virDomainDiskGetType(virDomainDiskDefPtr def); int virDomainDiskGetType(virDomainDiskDefPtr def);
void virDomainDiskSetType(virDomainDiskDefPtr def, int type); void virDomainDiskSetType(virDomainDiskDefPtr def, int type);
int virDomainDiskGetActualType(virDomainDiskDefPtr def); int virDomainDiskGetActualType(virDomainDiskDefPtr def);
...@@ -2388,7 +2367,7 @@ int virDomainDiskSourceDefFormatInternal(virBufferPtr buf, ...@@ -2388,7 +2367,7 @@ int virDomainDiskSourceDefFormatInternal(virBufferPtr buf,
int policy, int policy,
int protocol, int protocol,
size_t nhosts, size_t nhosts,
virDomainDiskHostDefPtr hosts, virStorageNetHostDefPtr hosts,
size_t nseclabels, size_t nseclabels,
virSecurityDeviceLabelDefPtr *seclabels, virSecurityDeviceLabelDefPtr *seclabels,
virDomainDiskSourcePoolDefPtr srcpool, virDomainDiskSourcePoolDefPtr srcpool,
...@@ -2444,7 +2423,7 @@ int virDomainDiskSourceDefParse(xmlNodePtr node, ...@@ -2444,7 +2423,7 @@ int virDomainDiskSourceDefParse(xmlNodePtr node,
char **source, char **source,
int *proto, int *proto,
size_t *nhosts, size_t *nhosts,
virDomainDiskHostDefPtr *hosts, virStorageNetHostDefPtr *hosts,
virDomainDiskSourcePoolDefPtr *srcpool); virDomainDiskSourcePoolDefPtr *srcpool);
bool virDomainHasDiskMirror(virDomainObjPtr vm); bool virDomainHasDiskMirror(virDomainObjPtr vm);
...@@ -2664,7 +2643,6 @@ VIR_ENUM_DECL(virDomainDiskBus) ...@@ -2664,7 +2643,6 @@ VIR_ENUM_DECL(virDomainDiskBus)
VIR_ENUM_DECL(virDomainDiskCache) VIR_ENUM_DECL(virDomainDiskCache)
VIR_ENUM_DECL(virDomainDiskErrorPolicy) VIR_ENUM_DECL(virDomainDiskErrorPolicy)
VIR_ENUM_DECL(virDomainDiskProtocol) VIR_ENUM_DECL(virDomainDiskProtocol)
VIR_ENUM_DECL(virDomainDiskProtocolTransport)
VIR_ENUM_DECL(virDomainDiskIo) VIR_ENUM_DECL(virDomainDiskIo)
VIR_ENUM_DECL(virDomainDiskSecretType) VIR_ENUM_DECL(virDomainDiskSecretType)
VIR_ENUM_DECL(virDomainDeviceSGIO) VIR_ENUM_DECL(virDomainDeviceSGIO)
......
...@@ -84,9 +84,8 @@ virDomainSnapshotDiskDefClear(virDomainSnapshotDiskDefPtr disk) ...@@ -84,9 +84,8 @@ virDomainSnapshotDiskDefClear(virDomainSnapshotDiskDefPtr disk)
{ {
VIR_FREE(disk->name); VIR_FREE(disk->name);
VIR_FREE(disk->file); VIR_FREE(disk->file);
while (disk->nhosts) virStorageNetHostDefFree(disk->nhosts, disk->hosts);
virDomainDiskHostDefClear(&disk->hosts[--disk->nhosts]); disk->nhosts = 0;
VIR_FREE(disk->hosts);
} }
void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def) void virDomainSnapshotDefFree(virDomainSnapshotDefPtr def)
......
/* /*
* snapshot_conf.h: domain snapshot XML processing * snapshot_conf.h: domain snapshot XML processing
* *
* Copyright (C) 2006-2013 Red Hat, Inc. * Copyright (C) 2006-2014 Red Hat, Inc.
* Copyright (C) 2006-2008 Daniel P. Berrange * Copyright (C) 2006-2008 Daniel P. Berrange
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
...@@ -56,7 +56,7 @@ struct _virDomainSnapshotDiskDef { ...@@ -56,7 +56,7 @@ struct _virDomainSnapshotDiskDef {
int format; /* enum virStorageFileFormat */ int format; /* enum virStorageFileFormat */
int protocol; /* network source protocol */ int protocol; /* network source protocol */
size_t nhosts; /* network source hosts count */ size_t nhosts; /* network source hosts count */
virDomainDiskHostDefPtr hosts; /* network source hosts */ virStorageNetHostDefPtr hosts; /* network source hosts */
}; };
/* Stores the complete snapshot metadata */ /* Stores the complete snapshot metadata */
......
...@@ -203,17 +203,12 @@ virDomainDiskGetDriver; ...@@ -203,17 +203,12 @@ virDomainDiskGetDriver;
virDomainDiskGetFormat; virDomainDiskGetFormat;
virDomainDiskGetSource; virDomainDiskGetSource;
virDomainDiskGetType; virDomainDiskGetType;
virDomainDiskHostDefClear;
virDomainDiskHostDefCopy;
virDomainDiskHostDefFree;
virDomainDiskIndexByName; virDomainDiskIndexByName;
virDomainDiskInsert; virDomainDiskInsert;
virDomainDiskInsertPreAlloced; virDomainDiskInsertPreAlloced;
virDomainDiskIoTypeFromString; virDomainDiskIoTypeFromString;
virDomainDiskIoTypeToString; virDomainDiskIoTypeToString;
virDomainDiskPathByName; virDomainDiskPathByName;
virDomainDiskProtocolTransportTypeFromString;
virDomainDiskProtocolTransportTypeToString;
virDomainDiskProtocolTypeToString; virDomainDiskProtocolTypeToString;
virDomainDiskRemove; virDomainDiskRemove;
virDomainDiskRemoveByName; virDomainDiskRemoveByName;
...@@ -1842,6 +1837,11 @@ virStorageFileIsSharedFSType; ...@@ -1842,6 +1837,11 @@ virStorageFileIsSharedFSType;
virStorageFileProbeFormat; virStorageFileProbeFormat;
virStorageFileProbeFormatFromBuf; virStorageFileProbeFormatFromBuf;
virStorageFileResize; virStorageFileResize;
virStorageNetHostDefClear;
virStorageNetHostDefCopy;
virStorageNetHostDefFree;
virStorageNetHostTransportTypeFromString;
virStorageNetHostTransportTypeToString;
# util/virstring.h # util/virstring.h
......
...@@ -3285,7 +3285,7 @@ static int qemuAddRBDHost(virDomainDiskDefPtr disk, char *hostport) ...@@ -3285,7 +3285,7 @@ static int qemuAddRBDHost(virDomainDiskDefPtr disk, char *hostport)
if (!disk->src.hosts[disk->src.nhosts-1].name) if (!disk->src.hosts[disk->src.nhosts-1].name)
goto error; goto error;
disk->src.hosts[disk->src.nhosts-1].transport = VIR_DOMAIN_DISK_PROTO_TRANS_TCP; disk->src.hosts[disk->src.nhosts-1].transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
disk->src.hosts[disk->src.nhosts-1].socket = NULL; disk->src.hosts[disk->src.nhosts-1].socket = NULL;
return 0; return 0;
...@@ -3388,9 +3388,9 @@ qemuParseDriveURIString(virDomainDiskDefPtr def, virURIPtr uri, ...@@ -3388,9 +3388,9 @@ qemuParseDriveURIString(virDomainDiskDefPtr def, virURIPtr uri,
} }
if (!transp) { if (!transp) {
def->src.hosts->transport = VIR_DOMAIN_DISK_PROTO_TRANS_TCP; def->src.hosts->transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
} else { } else {
def->src.hosts->transport = virDomainDiskProtocolTransportTypeFromString(transp); def->src.hosts->transport = virStorageNetHostTransportTypeFromString(transp);
if (def->src.hosts->transport < 0) { if (def->src.hosts->transport < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("Invalid %s transport type '%s'"), scheme, transp); _("Invalid %s transport type '%s'"), scheme, transp);
...@@ -3399,7 +3399,7 @@ qemuParseDriveURIString(virDomainDiskDefPtr def, virURIPtr uri, ...@@ -3399,7 +3399,7 @@ qemuParseDriveURIString(virDomainDiskDefPtr def, virURIPtr uri,
} }
def->src.nhosts = 0; /* set to 1 once everything succeeds */ def->src.nhosts = 0; /* set to 1 once everything succeeds */
if (def->src.hosts->transport != VIR_DOMAIN_DISK_PROTO_TRANS_UNIX) { if (def->src.hosts->transport != VIR_STORAGE_NET_HOST_TRANS_UNIX) {
if (VIR_STRDUP(def->src.hosts->name, uri->server) < 0) if (VIR_STRDUP(def->src.hosts->name, uri->server) < 0)
goto error; goto error;
...@@ -3447,7 +3447,7 @@ qemuParseDriveURIString(virDomainDiskDefPtr def, virURIPtr uri, ...@@ -3447,7 +3447,7 @@ qemuParseDriveURIString(virDomainDiskDefPtr def, virURIPtr uri,
return ret; return ret;
error: error:
virDomainDiskHostDefClear(def->src.hosts); virStorageNetHostDefClear(def->src.hosts);
VIR_FREE(def->src.hosts); VIR_FREE(def->src.hosts);
goto cleanup; goto cleanup;
} }
...@@ -3492,7 +3492,7 @@ qemuParseISCSIString(virDomainDiskDefPtr def) ...@@ -3492,7 +3492,7 @@ qemuParseISCSIString(virDomainDiskDefPtr def)
static int static int
qemuParseNBDString(virDomainDiskDefPtr disk) qemuParseNBDString(virDomainDiskDefPtr disk)
{ {
virDomainDiskHostDefPtr h = NULL; virStorageNetHostDefPtr h = NULL;
char *host, *port; char *host, *port;
char *src; char *src;
...@@ -3513,7 +3513,7 @@ qemuParseNBDString(virDomainDiskDefPtr disk) ...@@ -3513,7 +3513,7 @@ qemuParseNBDString(virDomainDiskDefPtr disk)
if (src) if (src)
*src++ = '\0'; *src++ = '\0';
h->transport = VIR_DOMAIN_DISK_PROTO_TRANS_UNIX; h->transport = VIR_STORAGE_NET_HOST_TRANS_UNIX;
if (VIR_STRDUP(h->socket, host + strlen("unix:")) < 0) if (VIR_STRDUP(h->socket, host + strlen("unix:")) < 0)
goto error; goto error;
} else { } else {
...@@ -3550,7 +3550,7 @@ qemuParseNBDString(virDomainDiskDefPtr disk) ...@@ -3550,7 +3550,7 @@ qemuParseNBDString(virDomainDiskDefPtr disk)
return 0; return 0;
error: error:
virDomainDiskHostDefClear(h); virStorageNetHostDefClear(h);
VIR_FREE(h); VIR_FREE(h);
return -1; return -1;
} }
...@@ -3615,7 +3615,7 @@ char * ...@@ -3615,7 +3615,7 @@ char *
qemuBuildNetworkDriveURI(int protocol, qemuBuildNetworkDriveURI(int protocol,
const char *src, const char *src,
size_t nhosts, size_t nhosts,
virDomainDiskHostDefPtr hosts, virStorageNetHostDefPtr hosts,
const char *username, const char *username,
const char *secret) const char *secret)
{ {
...@@ -3634,23 +3634,23 @@ qemuBuildNetworkDriveURI(int protocol, ...@@ -3634,23 +3634,23 @@ qemuBuildNetworkDriveURI(int protocol,
} }
if (!((hosts->name && strchr(hosts->name, ':')) || if (!((hosts->name && strchr(hosts->name, ':')) ||
(hosts->transport == VIR_DOMAIN_DISK_PROTO_TRANS_TCP && (hosts->transport == VIR_STORAGE_NET_HOST_TRANS_TCP &&
!hosts->name) || !hosts->name) ||
(hosts->transport == VIR_DOMAIN_DISK_PROTO_TRANS_UNIX && (hosts->transport == VIR_STORAGE_NET_HOST_TRANS_UNIX &&
hosts->socket && hosts->socket &&
hosts->socket[0] != '/'))) { hosts->socket[0] != '/'))) {
virBufferAddLit(&buf, "nbd:"); virBufferAddLit(&buf, "nbd:");
switch (hosts->transport) { switch (hosts->transport) {
case VIR_DOMAIN_DISK_PROTO_TRANS_TCP: case VIR_STORAGE_NET_HOST_TRANS_TCP:
virBufferStrcat(&buf, hosts->name, NULL); virBufferStrcat(&buf, hosts->name, NULL);
virBufferAsprintf(&buf, ":%s", virBufferAsprintf(&buf, ":%s",
hosts->port ? hosts->port : hosts->port ? hosts->port :
QEMU_DEFAULT_NBD_PORT); QEMU_DEFAULT_NBD_PORT);
break; break;
case VIR_DOMAIN_DISK_PROTO_TRANS_UNIX: case VIR_STORAGE_NET_HOST_TRANS_UNIX:
if (!hosts->socket) { if (!hosts->socket) {
virReportError(VIR_ERR_INTERNAL_ERROR, "%s", virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
_("socket attribute required for " _("socket attribute required for "
...@@ -3664,7 +3664,7 @@ qemuBuildNetworkDriveURI(int protocol, ...@@ -3664,7 +3664,7 @@ qemuBuildNetworkDriveURI(int protocol,
default: default:
virReportError(VIR_ERR_INTERNAL_ERROR, virReportError(VIR_ERR_INTERNAL_ERROR,
_("nbd does not support transport '%s'"), _("nbd does not support transport '%s'"),
virDomainDiskProtocolTransportTypeToString(hosts->transport)); virStorageNetHostTransportTypeToString(hosts->transport));
goto cleanup; goto cleanup;
} }
...@@ -3699,14 +3699,14 @@ qemuBuildNetworkDriveURI(int protocol, ...@@ -3699,14 +3699,14 @@ qemuBuildNetworkDriveURI(int protocol,
if (VIR_ALLOC(uri) < 0) if (VIR_ALLOC(uri) < 0)
goto cleanup; goto cleanup;
if (hosts->transport == VIR_DOMAIN_DISK_PROTO_TRANS_TCP) { if (hosts->transport == VIR_STORAGE_NET_HOST_TRANS_TCP) {
if (VIR_STRDUP(uri->scheme, if (VIR_STRDUP(uri->scheme,
virDomainDiskProtocolTypeToString(protocol)) < 0) virDomainDiskProtocolTypeToString(protocol)) < 0)
goto cleanup; goto cleanup;
} else { } else {
if (virAsprintf(&uri->scheme, "%s+%s", if (virAsprintf(&uri->scheme, "%s+%s",
virDomainDiskProtocolTypeToString(protocol), virDomainDiskProtocolTypeToString(protocol),
virDomainDiskProtocolTransportTypeToString(hosts->transport)) < 0) virStorageNetHostTransportTypeToString(hosts->transport)) < 0)
goto cleanup; goto cleanup;
} }
...@@ -3826,7 +3826,7 @@ qemuGetDriveSourceString(int type, ...@@ -3826,7 +3826,7 @@ qemuGetDriveSourceString(int type,
const char *src, const char *src,
int protocol, int protocol,
size_t nhosts, size_t nhosts,
virDomainDiskHostDefPtr hosts, virStorageNetHostDefPtr hosts,
const char *username, const char *username,
const char *secret, const char *secret,
char **path) char **path)
...@@ -10274,7 +10274,7 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt, ...@@ -10274,7 +10274,7 @@ qemuParseCommandLineDisk(virDomainXMLOptionPtr xmlopt,
def->src.hosts->name = def->src.path; def->src.hosts->name = def->src.path;
if (VIR_STRDUP(def->src.hosts->port, port) < 0) if (VIR_STRDUP(def->src.hosts->port, port) < 0)
goto error; goto error;
def->src.hosts->transport = VIR_DOMAIN_DISK_PROTO_TRANS_TCP; def->src.hosts->transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
def->src.hosts->socket = NULL; def->src.hosts->socket = NULL;
if (VIR_STRDUP(def->src.path, vdi) < 0) if (VIR_STRDUP(def->src.path, vdi) < 0)
goto error; goto error;
...@@ -12070,7 +12070,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps, ...@@ -12070,7 +12070,7 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
VIR_FREE(hosts); VIR_FREE(hosts);
goto error; goto error;
} }
first_rbd_disk->src.hosts[first_rbd_disk->src.nhosts].transport = VIR_DOMAIN_DISK_PROTO_TRANS_TCP; first_rbd_disk->src.hosts[first_rbd_disk->src.nhosts].transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
first_rbd_disk->src.hosts[first_rbd_disk->src.nhosts].socket = NULL; first_rbd_disk->src.hosts[first_rbd_disk->src.nhosts].socket = NULL;
first_rbd_disk->src.nhosts++; first_rbd_disk->src.nhosts++;
......
/* /*
* qemu_command.h: QEMU command generation * qemu_command.h: QEMU command generation
* *
* Copyright (C) 2006-2013 Red Hat, Inc. * Copyright (C) 2006-2014 Red Hat, Inc.
* Copyright (C) 2006 Daniel P. Berrange * Copyright (C) 2006 Daniel P. Berrange
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
...@@ -185,7 +185,7 @@ char * qemuBuildRedirdevDevStr(virDomainDefPtr def, ...@@ -185,7 +185,7 @@ char * qemuBuildRedirdevDevStr(virDomainDefPtr def,
char *qemuBuildNetworkDriveURI(int proto, char *qemuBuildNetworkDriveURI(int proto,
const char *src, const char *src,
size_t nhosts, size_t nhosts,
virDomainDiskHostDefPtr hosts, virStorageNetHostDefPtr hosts,
const char *username, const char *username,
const char *secret); const char *secret);
...@@ -318,7 +318,7 @@ int qemuGetDriveSourceString(int type, ...@@ -318,7 +318,7 @@ int qemuGetDriveSourceString(int type,
const char *src, const char *src,
int protocol, int protocol,
size_t nhosts, size_t nhosts,
virDomainDiskHostDefPtr hosts, virStorageNetHostDefPtr hosts,
const char *username, const char *username,
const char *secret, const char *secret,
char **path); char **path);
......
...@@ -1192,7 +1192,7 @@ qemuAddISCSIPoolSourceHost(virDomainDiskDefPtr def, ...@@ -1192,7 +1192,7 @@ qemuAddISCSIPoolSourceHost(virDomainDiskDefPtr def,
/* Storage pool have not supported these 2 attributes yet, /* Storage pool have not supported these 2 attributes yet,
* use the defaults. * use the defaults.
*/ */
def->src.hosts[0].transport = VIR_DOMAIN_DISK_PROTO_TRANS_TCP; def->src.hosts[0].transport = VIR_STORAGE_NET_HOST_TRANS_TCP;
def->src.hosts[0].socket = NULL; def->src.hosts[0].socket = NULL;
def->src.protocol = VIR_DOMAIN_DISK_PROTOCOL_ISCSI; def->src.protocol = VIR_DOMAIN_DISK_PROTOCOL_ISCSI;
...@@ -1309,7 +1309,7 @@ qemuTranslateDiskSourcePool(virConnectPtr conn, ...@@ -1309,7 +1309,7 @@ qemuTranslateDiskSourcePool(virConnectPtr conn,
} }
VIR_FREE(def->src.path); VIR_FREE(def->src.path);
virDomainDiskHostDefFree(def->src.nhosts, def->src.hosts); virStorageNetHostDefFree(def->src.nhosts, def->src.hosts);
virDomainDiskAuthClear(&def->src); virDomainDiskAuthClear(&def->src);
switch ((enum virStoragePoolType) pooldef->type) { switch ((enum virStoragePoolType) pooldef->type) {
......
...@@ -12748,8 +12748,8 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver, ...@@ -12748,8 +12748,8 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
char *device = NULL; char *device = NULL;
char *source = NULL; char *source = NULL;
char *newsource = NULL; char *newsource = NULL;
virDomainDiskHostDefPtr newhosts = NULL; virStorageNetHostDefPtr newhosts = NULL;
virDomainDiskHostDefPtr persistHosts = NULL; virStorageNetHostDefPtr persistHosts = NULL;
int format = snap->format; int format = snap->format;
const char *formatStr = NULL; const char *formatStr = NULL;
char *persistSource = NULL; char *persistSource = NULL;
...@@ -12815,11 +12815,11 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver, ...@@ -12815,11 +12815,11 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
case VIR_DOMAIN_DISK_TYPE_NETWORK: case VIR_DOMAIN_DISK_TYPE_NETWORK:
switch (snap->protocol) { switch (snap->protocol) {
case VIR_DOMAIN_DISK_PROTOCOL_GLUSTER: case VIR_DOMAIN_DISK_PROTOCOL_GLUSTER:
if (!(newhosts = virDomainDiskHostDefCopy(snap->nhosts, snap->hosts))) if (!(newhosts = virStorageNetHostDefCopy(snap->nhosts, snap->hosts)))
goto cleanup; goto cleanup;
if (persistDisk && if (persistDisk &&
!(persistHosts = virDomainDiskHostDefCopy(snap->nhosts, snap->hosts))) !(persistHosts = virStorageNetHostDefCopy(snap->nhosts, snap->hosts)))
goto cleanup; goto cleanup;
break; break;
...@@ -12870,7 +12870,7 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver, ...@@ -12870,7 +12870,7 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
need_unlink = false; need_unlink = false;
VIR_FREE(disk->src.path); VIR_FREE(disk->src.path);
virDomainDiskHostDefFree(disk->src.nhosts, disk->src.hosts); virStorageNetHostDefFree(disk->src.nhosts, disk->src.hosts);
disk->src.path = newsource; disk->src.path = newsource;
disk->src.format = format; disk->src.format = format;
...@@ -12884,7 +12884,7 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver, ...@@ -12884,7 +12884,7 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
if (persistDisk) { if (persistDisk) {
VIR_FREE(persistDisk->src.path); VIR_FREE(persistDisk->src.path);
virDomainDiskHostDefFree(persistDisk->src.nhosts, virStorageNetHostDefFree(persistDisk->src.nhosts,
persistDisk->src.hosts); persistDisk->src.hosts);
persistDisk->src.path = persistSource; persistDisk->src.path = persistSource;
...@@ -12906,8 +12906,8 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver, ...@@ -12906,8 +12906,8 @@ qemuDomainSnapshotCreateSingleDiskActive(virQEMUDriverPtr driver,
VIR_FREE(source); VIR_FREE(source);
VIR_FREE(newsource); VIR_FREE(newsource);
VIR_FREE(persistSource); VIR_FREE(persistSource);
virDomainDiskHostDefFree(snap->nhosts, newhosts); virStorageNetHostDefFree(snap->nhosts, newhosts);
virDomainDiskHostDefFree(snap->nhosts, persistHosts); virStorageNetHostDefFree(snap->nhosts, persistHosts);
return ret; return ret;
} }
...@@ -12947,9 +12947,9 @@ qemuDomainSnapshotUndoSingleDiskActive(virQEMUDriverPtr driver, ...@@ -12947,9 +12947,9 @@ qemuDomainSnapshotUndoSingleDiskActive(virQEMUDriverPtr driver,
disk->src.format = origdisk->src.format; disk->src.format = origdisk->src.format;
disk->src.type = origdisk->src.type; disk->src.type = origdisk->src.type;
disk->src.protocol = origdisk->src.protocol; disk->src.protocol = origdisk->src.protocol;
virDomainDiskHostDefFree(disk->src.nhosts, disk->src.hosts); virStorageNetHostDefFree(disk->src.nhosts, disk->src.hosts);
disk->src.nhosts = origdisk->src.nhosts; disk->src.nhosts = origdisk->src.nhosts;
disk->src.hosts = virDomainDiskHostDefCopy(origdisk->src.nhosts, disk->src.hosts = virStorageNetHostDefCopy(origdisk->src.nhosts,
origdisk->src.hosts); origdisk->src.hosts);
if (persistDisk) { if (persistDisk) {
VIR_FREE(persistDisk->src.path); VIR_FREE(persistDisk->src.path);
...@@ -12958,10 +12958,10 @@ qemuDomainSnapshotUndoSingleDiskActive(virQEMUDriverPtr driver, ...@@ -12958,10 +12958,10 @@ qemuDomainSnapshotUndoSingleDiskActive(virQEMUDriverPtr driver,
persistDisk->src.format = origdisk->src.format; persistDisk->src.format = origdisk->src.format;
persistDisk->src.type = origdisk->src.type; persistDisk->src.type = origdisk->src.type;
persistDisk->src.protocol = origdisk->src.protocol; persistDisk->src.protocol = origdisk->src.protocol;
virDomainDiskHostDefFree(persistDisk->src.nhosts, virStorageNetHostDefFree(persistDisk->src.nhosts,
persistDisk->src.hosts); persistDisk->src.hosts);
persistDisk->src.nhosts = origdisk->src.nhosts; persistDisk->src.nhosts = origdisk->src.nhosts;
persistDisk->src.hosts = virDomainDiskHostDefCopy(origdisk->src.nhosts, persistDisk->src.hosts = virStorageNetHostDefCopy(origdisk->src.nhosts,
origdisk->src.hosts); origdisk->src.hosts);
} }
......
/* /*
* storage_backend_gluster.c: storage backend for Gluster handling * storage_backend_gluster.c: storage backend for Gluster handling
* *
* Copyright (C) 2013 Red Hat, Inc. * Copyright (C) 2013-2014 Red Hat, Inc.
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
...@@ -566,7 +566,7 @@ static int ...@@ -566,7 +566,7 @@ static int
virStorageFileBackendGlusterInit(virStorageFilePtr file) virStorageFileBackendGlusterInit(virStorageFilePtr file)
{ {
virStorageFileBackendGlusterPrivPtr priv = NULL; virStorageFileBackendGlusterPrivPtr priv = NULL;
virDomainDiskHostDefPtr host = &(file->hosts[0]); virStorageNetHostDefPtr host = &(file->hosts[0]);
const char *hostname = host->name; const char *hostname = host->name;
int port = 0; int port = 0;
...@@ -597,7 +597,7 @@ virStorageFileBackendGlusterInit(virStorageFilePtr file) ...@@ -597,7 +597,7 @@ virStorageFileBackendGlusterInit(virStorageFilePtr file)
goto error; goto error;
} }
if (host->transport == VIR_DOMAIN_DISK_PROTO_TRANS_UNIX) if (host->transport == VIR_STORAGE_NET_HOST_TRANS_UNIX)
hostname = host->socket; hostname = host->socket;
...@@ -607,7 +607,7 @@ virStorageFileBackendGlusterInit(virStorageFilePtr file) ...@@ -607,7 +607,7 @@ virStorageFileBackendGlusterInit(virStorageFilePtr file)
} }
if (glfs_set_volfile_server(priv->vol, if (glfs_set_volfile_server(priv->vol,
virDomainDiskProtocolTransportTypeToString(host->transport), virStorageNetHostTransportTypeToString(host->transport),
hostname, port) < 0) { hostname, port) < 0) {
virReportSystemError(errno, virReportSystemError(errno,
_("failed to set gluster volfile server '%s'"), _("failed to set gluster volfile server '%s'"),
......
...@@ -2742,7 +2742,7 @@ virStorageFileFree(virStorageFilePtr file) ...@@ -2742,7 +2742,7 @@ virStorageFileFree(virStorageFilePtr file)
file->backend->backendDeinit(file); file->backend->backendDeinit(file);
VIR_FREE(file->path); VIR_FREE(file->path);
virDomainDiskHostDefFree(file->nhosts, file->hosts); virStorageNetHostDefFree(file->nhosts, file->hosts);
VIR_FREE(file); VIR_FREE(file);
} }
...@@ -2752,7 +2752,7 @@ virStorageFileInitInternal(int type, ...@@ -2752,7 +2752,7 @@ virStorageFileInitInternal(int type,
const char *path, const char *path,
int protocol, int protocol,
size_t nhosts, size_t nhosts,
virDomainDiskHostDefPtr hosts) virStorageNetHostDefPtr hosts)
{ {
virStorageFilePtr file = NULL; virStorageFilePtr file = NULL;
...@@ -2766,7 +2766,7 @@ virStorageFileInitInternal(int type, ...@@ -2766,7 +2766,7 @@ virStorageFileInitInternal(int type,
if (VIR_STRDUP(file->path, path) < 0) if (VIR_STRDUP(file->path, path) < 0)
goto error; goto error;
if (!(file->hosts = virDomainDiskHostDefCopy(nhosts, hosts))) if (!(file->hosts = virStorageNetHostDefCopy(nhosts, hosts)))
goto error; goto error;
if (!(file->backend = virStorageFileBackendForType(file->type, if (!(file->backend = virStorageFileBackendForType(file->type,
...@@ -2781,7 +2781,7 @@ virStorageFileInitInternal(int type, ...@@ -2781,7 +2781,7 @@ virStorageFileInitInternal(int type,
error: error:
VIR_FREE(file->path); VIR_FREE(file->path);
virDomainDiskHostDefFree(file->nhosts, file->hosts); virStorageNetHostDefFree(file->nhosts, file->hosts);
VIR_FREE(file); VIR_FREE(file);
return NULL; return NULL;
} }
......
...@@ -42,7 +42,7 @@ struct _virStorageFile { ...@@ -42,7 +42,7 @@ struct _virStorageFile {
int protocol; int protocol;
size_t nhosts; size_t nhosts;
virDomainDiskHostDefPtr hosts; virStorageNetHostDefPtr hosts;
}; };
virStorageFilePtr virStorageFilePtr
......
/* /*
* virstoragefile.c: file utility functions for FS storage backend * virstoragefile.c: file utility functions for FS storage backend
* *
* Copyright (C) 2007-2013 Red Hat, Inc. * Copyright (C) 2007-2014 Red Hat, Inc.
* Copyright (C) 2007-2008 Daniel P. Berrange * Copyright (C) 2007-2008 Daniel P. Berrange
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
...@@ -66,6 +66,13 @@ VIR_ENUM_IMPL(virStorageFileFeature, ...@@ -66,6 +66,13 @@ VIR_ENUM_IMPL(virStorageFileFeature,
"lazy_refcounts", "lazy_refcounts",
) )
VIR_ENUM_IMPL(virStorageNetHostTransport, VIR_STORAGE_NET_HOST_TRANS_LAST,
"tcp",
"unix",
"rdma")
enum lv_endian { enum lv_endian {
LV_LITTLE_ENDIAN = 1, /* 1234 */ LV_LITTLE_ENDIAN = 1, /* 1234 */
LV_BIG_ENDIAN /* 4321 */ LV_BIG_ENDIAN /* 4321 */
...@@ -1556,3 +1563,65 @@ virStorageFileChainLookup(virStorageFileMetadataPtr chain, const char *start, ...@@ -1556,3 +1563,65 @@ virStorageFileChainLookup(virStorageFileMetadataPtr chain, const char *start,
*meta = NULL; *meta = NULL;
return NULL; return NULL;
} }
void
virStorageNetHostDefClear(virStorageNetHostDefPtr def)
{
if (!def)
return;
VIR_FREE(def->name);
VIR_FREE(def->port);
VIR_FREE(def->socket);
}
void
virStorageNetHostDefFree(size_t nhosts,
virStorageNetHostDefPtr hosts)
{
size_t i;
if (!hosts)
return;
for (i = 0; i < nhosts; i++)
virStorageNetHostDefClear(&hosts[i]);
VIR_FREE(hosts);
}
virStorageNetHostDefPtr
virStorageNetHostDefCopy(size_t nhosts,
virStorageNetHostDefPtr hosts)
{
virStorageNetHostDefPtr ret = NULL;
size_t i;
if (VIR_ALLOC_N(ret, nhosts) < 0)
goto error;
for (i = 0; i < nhosts; i++) {
virStorageNetHostDefPtr src = &hosts[i];
virStorageNetHostDefPtr dst = &ret[i];
dst->transport = src->transport;
if (VIR_STRDUP(dst->name, src->name) < 0)
goto error;
if (VIR_STRDUP(dst->port, src->port) < 0)
goto error;
if (VIR_STRDUP(dst->socket, src->socket) < 0)
goto error;
}
return ret;
error:
virStorageNetHostDefFree(nhosts, ret);
return NULL;
}
/* /*
* virstoragefile.h: file utility functions for FS storage backend * virstoragefile.h: file utility functions for FS storage backend
* *
* Copyright (C) 2007-2009, 2012-2013 Red Hat, Inc. * Copyright (C) 2007-2009, 2012-2014 Red Hat, Inc.
* Copyright (C) 2007-2008 Daniel P. Berrange * Copyright (C) 2007-2008 Daniel P. Berrange
* *
* This library is free software; you can redistribute it and/or * This library is free software; you can redistribute it and/or
...@@ -83,6 +83,28 @@ struct _virStorageFileMetadata { ...@@ -83,6 +83,28 @@ struct _virStorageFileMetadata {
char *compat; char *compat;
}; };
/* Information related to network storage */
enum virStorageNetHostTransport {
VIR_STORAGE_NET_HOST_TRANS_TCP,
VIR_STORAGE_NET_HOST_TRANS_UNIX,
VIR_STORAGE_NET_HOST_TRANS_RDMA,
VIR_STORAGE_NET_HOST_TRANS_LAST
};
VIR_ENUM_DECL(virStorageNetHostTransport)
typedef struct _virStorageNetHostDef virStorageNetHostDef;
typedef virStorageNetHostDef *virStorageNetHostDefPtr;
struct _virStorageNetHostDef {
char *name;
char *port;
int transport; /* enum virStorageNetHostTransport */
char *socket; /* path to unix socket */
};
# ifndef DEV_BSIZE # ifndef DEV_BSIZE
# define DEV_BSIZE 512 # define DEV_BSIZE 512
# endif # endif
...@@ -138,4 +160,10 @@ int virStorageFileGetLVMKey(const char *path, ...@@ -138,4 +160,10 @@ int virStorageFileGetLVMKey(const char *path,
int virStorageFileGetSCSIKey(const char *path, int virStorageFileGetSCSIKey(const char *path,
char **key); char **key);
void virStorageNetHostDefClear(virStorageNetHostDefPtr def);
void virStorageNetHostDefFree(size_t nhosts, virStorageNetHostDefPtr hosts);
virStorageNetHostDefPtr virStorageNetHostDefCopy(size_t nhosts,
virStorageNetHostDefPtr hosts);
#endif /* __VIR_STORAGE_FILE_H__ */ #endif /* __VIR_STORAGE_FILE_H__ */
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册