mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 07:17:44 +00:00
conf: accessors for common source information
A future patch will split virDomainDiskDef, in order to track multiple host resources per guest <disk>. To reduce the size of that patch, I've factored out the four most common accesses into functions, so that I can incrementally upgrade the code base to use the accessors, and so that code that doesn't care about the distinction of per-file details won't have to be changed when the struct changes. * src/conf/domain_conf.h (virDomainDiskGetType) (virDomainDiskSetType, virDomainDiskGetSource) (virDomainDiskSetSource, virDomainDiskGetDriver) (virDomainDiskSetDriver, virDomainDiskGetFormat) (virDomainDiskSetFormat): New prototypes. * src/conf/domain_conf.c (virDomainDiskGetType) (virDomainDiskSetType, virDomainDiskGetSource) (virDomainDiskSetSource, virDomainDiskGetDriver) (virDomainDiskSetDriver, virDomainDiskGetFormat) (virDomainDiskSetFormat): Implement them. * src/libvirt_private.syms (domain_conf.h): Export them. Signed-off-by: Eric Blake <eblake@redhat.com>
This commit is contained in:
parent
e7b0e71d92
commit
1014c34e3c
@ -1354,6 +1354,20 @@ error:
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
virDomainDiskGetType(virDomainDiskDefPtr def)
|
||||||
|
{
|
||||||
|
return def->type;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
virDomainDiskSetType(virDomainDiskDefPtr def, int type)
|
||||||
|
{
|
||||||
|
def->type = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int
|
int
|
||||||
virDomainDiskGetActualType(virDomainDiskDefPtr def)
|
virDomainDiskGetActualType(virDomainDiskDefPtr def)
|
||||||
{
|
{
|
||||||
@ -1364,6 +1378,64 @@ virDomainDiskGetActualType(virDomainDiskDefPtr def)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char *
|
||||||
|
virDomainDiskGetSource(virDomainDiskDefPtr def)
|
||||||
|
{
|
||||||
|
return def->src;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
char *tmp = def->src;
|
||||||
|
|
||||||
|
ret = VIR_STRDUP(def->src, src);
|
||||||
|
if (ret < 0)
|
||||||
|
def->src = tmp;
|
||||||
|
else
|
||||||
|
VIR_FREE(tmp);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const char *
|
||||||
|
virDomainDiskGetDriver(virDomainDiskDefPtr def)
|
||||||
|
{
|
||||||
|
return def->driverName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name)
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
char *tmp = def->driverName;
|
||||||
|
|
||||||
|
ret = VIR_STRDUP(def->driverName, name);
|
||||||
|
if (ret < 0)
|
||||||
|
def->driverName = tmp;
|
||||||
|
else
|
||||||
|
VIR_FREE(tmp);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int
|
||||||
|
virDomainDiskGetFormat(virDomainDiskDefPtr def)
|
||||||
|
{
|
||||||
|
return def->format;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void
|
||||||
|
virDomainDiskSetFormat(virDomainDiskDefPtr def, int format)
|
||||||
|
{
|
||||||
|
def->format = format;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void virDomainControllerDefFree(virDomainControllerDefPtr def)
|
void virDomainControllerDefFree(virDomainControllerDefPtr def)
|
||||||
{
|
{
|
||||||
if (!def)
|
if (!def)
|
||||||
|
@ -2256,7 +2256,17 @@ void virDomainDiskHostDefClear(virDomainDiskHostDefPtr def);
|
|||||||
void virDomainDiskHostDefFree(size_t nhosts, virDomainDiskHostDefPtr hosts);
|
void virDomainDiskHostDefFree(size_t nhosts, virDomainDiskHostDefPtr hosts);
|
||||||
virDomainDiskHostDefPtr virDomainDiskHostDefCopy(size_t nhosts,
|
virDomainDiskHostDefPtr virDomainDiskHostDefCopy(size_t nhosts,
|
||||||
virDomainDiskHostDefPtr hosts);
|
virDomainDiskHostDefPtr hosts);
|
||||||
|
int virDomainDiskGetType(virDomainDiskDefPtr def);
|
||||||
|
void virDomainDiskSetType(virDomainDiskDefPtr def, int type);
|
||||||
int virDomainDiskGetActualType(virDomainDiskDefPtr def);
|
int virDomainDiskGetActualType(virDomainDiskDefPtr def);
|
||||||
|
const char *virDomainDiskGetSource(virDomainDiskDefPtr def);
|
||||||
|
int virDomainDiskSetSource(virDomainDiskDefPtr def, const char *src)
|
||||||
|
ATTRIBUTE_RETURN_CHECK;
|
||||||
|
const char *virDomainDiskGetDriver(virDomainDiskDefPtr def);
|
||||||
|
int virDomainDiskSetDriver(virDomainDiskDefPtr def, const char *name)
|
||||||
|
ATTRIBUTE_RETURN_CHECK;
|
||||||
|
int virDomainDiskGetFormat(virDomainDiskDefPtr def);
|
||||||
|
void virDomainDiskSetFormat(virDomainDiskDefPtr def, int format);
|
||||||
int virDomainDeviceFindControllerModel(virDomainDefPtr def,
|
int virDomainDeviceFindControllerModel(virDomainDefPtr def,
|
||||||
virDomainDeviceInfoPtr info,
|
virDomainDeviceInfoPtr info,
|
||||||
int controllerType);
|
int controllerType);
|
||||||
|
@ -201,6 +201,10 @@ virDomainDiskFindByBusAndDst;
|
|||||||
virDomainDiskGeometryTransTypeFromString;
|
virDomainDiskGeometryTransTypeFromString;
|
||||||
virDomainDiskGeometryTransTypeToString;
|
virDomainDiskGeometryTransTypeToString;
|
||||||
virDomainDiskGetActualType;
|
virDomainDiskGetActualType;
|
||||||
|
virDomainDiskGetDriver;
|
||||||
|
virDomainDiskGetFormat;
|
||||||
|
virDomainDiskGetSource;
|
||||||
|
virDomainDiskGetType;
|
||||||
virDomainDiskHostDefClear;
|
virDomainDiskHostDefClear;
|
||||||
virDomainDiskHostDefCopy;
|
virDomainDiskHostDefCopy;
|
||||||
virDomainDiskHostDefFree;
|
virDomainDiskHostDefFree;
|
||||||
@ -215,6 +219,10 @@ virDomainDiskProtocolTransportTypeToString;
|
|||||||
virDomainDiskProtocolTypeToString;
|
virDomainDiskProtocolTypeToString;
|
||||||
virDomainDiskRemove;
|
virDomainDiskRemove;
|
||||||
virDomainDiskRemoveByName;
|
virDomainDiskRemoveByName;
|
||||||
|
virDomainDiskSetDriver;
|
||||||
|
virDomainDiskSetFormat;
|
||||||
|
virDomainDiskSetSource;
|
||||||
|
virDomainDiskSetType;
|
||||||
virDomainDiskSourceIsBlockType;
|
virDomainDiskSourceIsBlockType;
|
||||||
virDomainDiskTypeFromString;
|
virDomainDiskTypeFromString;
|
||||||
virDomainDiskTypeToString;
|
virDomainDiskTypeToString;
|
||||||
|
Loading…
Reference in New Issue
Block a user