提交 d2467709 编写于 作者: E Eric Blake

maint: avoid 'const fooPtr' in domain_conf

'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can).  But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).

Fix up offenders in src/conf/domain_conf, and their fallout.

Several things to note: virObjectLock() requires a non-const
argument; if this were C++, we could treat the locking field
as 'mutable' and allow locking an otherwise 'const' object, but
that is a more invasive change, so I instead dropped attempts
to be const-correct on domain lookup.  virXMLPropString and
friends require a non-const xmlNodePtr - this is because libxml2
is not a const-correct library.  We could make the src/util/virxml
wrappers cast away const, but I figured it was easier to not
try to mark xmlNodePtr as const.  Finally, virDomainDeviceDefCopy
was a rather hard conversion - it calls virDomainDeviceDefPostParse,
which in turn in the xen driver was actually modifying the domain
outside of the current device being visited.  We should not be
adding a device on the first per-device callback, but waiting until
after all per-device callbacks are complete.

* src/conf/domain_conf.h (virDomainObjListFindByID)
(virDomainObjListFindByUUID, virDomainObjListFindByName)
(virDomainObjAssignDef, virDomainObjListAdd): Drop attempt at
const.
(virDomainDeviceDefCopy): Use intended type.
(virDomainDeviceDefParse, virDomainDeviceDefPostParseCallback)
(virDomainVideoDefaultType, virDomainVideoDefaultRAM)
(virDomainChrGetDomainPtrs): Make const-correct.
* src/conf/domain_conf.c (virDomainObjListFindByID)
(virDomainObjListFindByUUID, virDomainObjListFindByName)
(virDomainDeviceDefCopy, virDomainObjListAdd)
(virDomainObjAssignDef, virDomainHostdevSubsysUsbDefParseXML)
(virDomainHostdevSubsysPciOrigStatesDefParseXML)
(virDomainHostdevSubsysPciDefParseXML)
(virDomainHostdevSubsysScsiDefParseXML)
(virDomainControllerModelTypeFromString)
(virDomainTPMDefParseXML, virDomainTimerDefParseXML)
(virDomainSoundCodecDefParseXML, virDomainSoundDefParseXML)
(virDomainWatchdogDefParseXML, virDomainRNGDefParseXML)
(virDomainMemballoonDefParseXML, virDomainNVRAMDefParseXML)
(virSysinfoParseXML, virDomainVideoAccelDefParseXML)
(virDomainVideoDefParseXML, virDomainHostdevDefParseXML)
(virDomainRedirdevDefParseXML)
(virDomainRedirFilterUsbDevDefParseXML)
(virDomainRedirFilterDefParseXML, virDomainIdMapEntrySort)
(virDomainIdmapDefParseXML, virDomainVcpuPinDefParseXML)
(virDiskNameToBusDeviceIndex, virDomainDeviceDefCopy)
(virDomainVideoDefaultType, virDomainHostdevAssignAddress)
(virDomainDeviceDefPostParseInternal, virDomainDeviceDefPostParse)
(virDomainChrGetDomainPtrs, virDomainControllerSCSINextUnit)
(virDomainSCSIDriveAddressIsUsed)
(virDomainDriveAddressIsUsedByDisk)
(virDomainDriveAddressIsUsedByHostdev): Fix fallout.
* src/openvz/openvz_driver.c (openvzDomainDeviceDefPostParse):
Likewise.
* src/libxl/libxl_domain.c (libxlDomainDeviceDefPostParse):
Likewise.
* src/qemu/qemu_domain.c (qemuDomainDeviceDefPostParse)
(qemuDomainDefaultNetModel): Likewise.
* src/lxc/lxc_domain.c (virLXCDomainDeviceDefPostParse):
Likewise.
* src/uml/uml_driver.c (umlDomainDeviceDefPostParse): Likewise.
* src/xen/xen_driver.c (xenDomainDeviceDefPostParse): Split...
(xenDomainDefPostParse): ...since per-device callback is not the
time to be adding a device.
Signed-off-by: NEric Blake <eblake@redhat.com>
上级 f8fa2b3e
...@@ -990,7 +990,7 @@ static int virDomainObjListSearchID(const void *payload, ...@@ -990,7 +990,7 @@ static int virDomainObjListSearchID(const void *payload,
return want; return want;
} }
virDomainObjPtr virDomainObjListFindByID(const virDomainObjListPtr doms, virDomainObjPtr virDomainObjListFindByID(virDomainObjListPtr doms,
int id) int id)
{ {
virDomainObjPtr obj; virDomainObjPtr obj;
...@@ -1003,7 +1003,7 @@ virDomainObjPtr virDomainObjListFindByID(const virDomainObjListPtr doms, ...@@ -1003,7 +1003,7 @@ virDomainObjPtr virDomainObjListFindByID(const virDomainObjListPtr doms,
} }
virDomainObjPtr virDomainObjListFindByUUID(const virDomainObjListPtr doms, virDomainObjPtr virDomainObjListFindByUUID(virDomainObjListPtr doms,
const unsigned char *uuid) const unsigned char *uuid)
{ {
char uuidstr[VIR_UUID_STRING_BUFLEN]; char uuidstr[VIR_UUID_STRING_BUFLEN];
...@@ -1033,7 +1033,7 @@ static int virDomainObjListSearchName(const void *payload, ...@@ -1033,7 +1033,7 @@ static int virDomainObjListSearchName(const void *payload,
return want; return want;
} }
virDomainObjPtr virDomainObjListFindByName(const virDomainObjListPtr doms, virDomainObjPtr virDomainObjListFindByName(virDomainObjListPtr doms,
const char *name) const char *name)
{ {
virDomainObjPtr obj; virDomainObjPtr obj;
...@@ -2091,7 +2091,7 @@ virDomainDefPtr virDomainDefNew(const char *name, ...@@ -2091,7 +2091,7 @@ virDomainDefPtr virDomainDefNew(const char *name,
void virDomainObjAssignDef(virDomainObjPtr domain, void virDomainObjAssignDef(virDomainObjPtr domain,
const virDomainDefPtr def, virDomainDefPtr def,
bool live, bool live,
virDomainDefPtr *oldDef) virDomainDefPtr *oldDef)
{ {
...@@ -2138,7 +2138,7 @@ void virDomainObjAssignDef(virDomainObjPtr domain, ...@@ -2138,7 +2138,7 @@ void virDomainObjAssignDef(virDomainObjPtr domain,
*/ */
static virDomainObjPtr static virDomainObjPtr
virDomainObjListAddLocked(virDomainObjListPtr doms, virDomainObjListAddLocked(virDomainObjListPtr doms,
const virDomainDefPtr def, virDomainDefPtr def,
virDomainXMLOptionPtr xmlopt, virDomainXMLOptionPtr xmlopt,
unsigned int flags, unsigned int flags,
virDomainDefPtr *oldDef) virDomainDefPtr *oldDef)
...@@ -2209,7 +2209,7 @@ error: ...@@ -2209,7 +2209,7 @@ error:
virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms, virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms,
const virDomainDefPtr def, virDomainDefPtr def,
virDomainXMLOptionPtr xmlopt, virDomainXMLOptionPtr xmlopt,
unsigned int flags, unsigned int flags,
virDomainDefPtr *oldDef) virDomainDefPtr *oldDef)
...@@ -2802,7 +2802,7 @@ virDomainDefPostParseInternal(virDomainDefPtr def, ...@@ -2802,7 +2802,7 @@ virDomainDefPostParseInternal(virDomainDefPtr def,
static int static int
virDomainDeviceDefPostParseInternal(virDomainDeviceDefPtr dev, virDomainDeviceDefPostParseInternal(virDomainDeviceDefPtr dev,
virDomainDefPtr def, const virDomainDef *def,
virCapsPtr caps ATTRIBUTE_UNUSED) virCapsPtr caps ATTRIBUTE_UNUSED)
{ {
if (dev->type == VIR_DOMAIN_DEVICE_CHR) { if (dev->type == VIR_DOMAIN_DEVICE_CHR) {
...@@ -2852,7 +2852,7 @@ virDomainDeviceDefPostParseInternal(virDomainDeviceDefPtr dev, ...@@ -2852,7 +2852,7 @@ virDomainDeviceDefPostParseInternal(virDomainDeviceDefPtr dev,
static int static int
virDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, virDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
virDomainDefPtr def, const virDomainDef *def,
virCapsPtr caps, virCapsPtr caps,
virDomainXMLOptionPtr xmlopt) virDomainXMLOptionPtr xmlopt)
{ {
...@@ -3548,7 +3548,7 @@ virDomainParseLegacyDeviceAddress(char *devaddr, ...@@ -3548,7 +3548,7 @@ virDomainParseLegacyDeviceAddress(char *devaddr,
} }
static int static int
virDomainHostdevSubsysUsbDefParseXML(const xmlNodePtr node, virDomainHostdevSubsysUsbDefParseXML(xmlNodePtr node,
virDomainHostdevDefPtr def) virDomainHostdevDefPtr def)
{ {
...@@ -3698,7 +3698,7 @@ out: ...@@ -3698,7 +3698,7 @@ out:
* </origstates> * </origstates>
*/ */
static int static int
virDomainHostdevSubsysPciOrigStatesDefParseXML(const xmlNodePtr node, virDomainHostdevSubsysPciOrigStatesDefParseXML(xmlNodePtr node,
virDomainHostdevOrigStatesPtr def) virDomainHostdevOrigStatesPtr def)
{ {
xmlNodePtr cur; xmlNodePtr cur;
...@@ -3726,7 +3726,7 @@ virDomainHostdevSubsysPciOrigStatesDefParseXML(const xmlNodePtr node, ...@@ -3726,7 +3726,7 @@ virDomainHostdevSubsysPciOrigStatesDefParseXML(const xmlNodePtr node,
} }
static int static int
virDomainHostdevSubsysPciDefParseXML(const xmlNodePtr node, virDomainHostdevSubsysPciDefParseXML(xmlNodePtr node,
virDomainHostdevDefPtr def, virDomainHostdevDefPtr def,
unsigned int flags) unsigned int flags)
{ {
...@@ -3777,7 +3777,7 @@ out: ...@@ -3777,7 +3777,7 @@ out:
} }
static int static int
virDomainHostdevSubsysScsiDefParseXML(const xmlNodePtr node, virDomainHostdevSubsysScsiDefParseXML(xmlNodePtr node,
virDomainHostdevDefPtr def) virDomainHostdevDefPtr def)
{ {
int ret = -1; int ret = -1;
...@@ -3868,7 +3868,7 @@ cleanup: ...@@ -3868,7 +3868,7 @@ cleanup:
* taken by a disk or not. * taken by a disk or not.
*/ */
static bool static bool
virDomainDriveAddressIsUsedByDisk(virDomainDefPtr def, virDomainDriveAddressIsUsedByDisk(const virDomainDef *def,
enum virDomainDiskBus type, enum virDomainDiskBus type,
unsigned int controller, unsigned int controller,
unsigned int unit) unsigned int unit)
...@@ -3897,7 +3897,7 @@ virDomainDriveAddressIsUsedByDisk(virDomainDefPtr def, ...@@ -3897,7 +3897,7 @@ virDomainDriveAddressIsUsedByDisk(virDomainDefPtr def,
* taken by a host device or not. * taken by a host device or not.
*/ */
static bool static bool
virDomainDriveAddressIsUsedByHostdev(virDomainDefPtr def, virDomainDriveAddressIsUsedByHostdev(const virDomainDef *def,
enum virDomainHostdevSubsysType type, enum virDomainHostdevSubsysType type,
unsigned int controller, unsigned int controller,
unsigned int unit) unsigned int unit)
...@@ -3922,7 +3922,7 @@ virDomainDriveAddressIsUsedByHostdev(virDomainDefPtr def, ...@@ -3922,7 +3922,7 @@ virDomainDriveAddressIsUsedByHostdev(virDomainDefPtr def,
} }
static bool static bool
virDomainSCSIDriveAddressIsUsed(virDomainDefPtr def, virDomainSCSIDriveAddressIsUsed(const virDomainDef *def,
unsigned int controller, unsigned int controller,
unsigned int unit) unsigned int unit)
{ {
...@@ -3943,7 +3943,7 @@ virDomainSCSIDriveAddressIsUsed(virDomainDefPtr def, ...@@ -3943,7 +3943,7 @@ virDomainSCSIDriveAddressIsUsed(virDomainDefPtr def,
/* Find out the next usable "unit" of a specific controller */ /* Find out the next usable "unit" of a specific controller */
static int static int
virDomainControllerSCSINextUnit(virDomainDefPtr def, virDomainControllerSCSINextUnit(const virDomainDef *def,
unsigned int max_unit, unsigned int max_unit,
unsigned int controller) unsigned int controller)
{ {
...@@ -3962,7 +3962,7 @@ virDomainControllerSCSINextUnit(virDomainDefPtr def, ...@@ -3962,7 +3962,7 @@ virDomainControllerSCSINextUnit(virDomainDefPtr def,
static int static int
virDomainHostdevAssignAddress(virDomainXMLOptionPtr xmlopt, virDomainHostdevAssignAddress(virDomainXMLOptionPtr xmlopt,
virDomainDefPtr def, const virDomainDef *def,
virDomainHostdevDefPtr hostdev) virDomainHostdevDefPtr hostdev)
{ {
int next_unit = 0; int next_unit = 0;
...@@ -5694,7 +5694,7 @@ cleanup: ...@@ -5694,7 +5694,7 @@ cleanup:
static int static int
virDomainControllerModelTypeFromString(const virDomainControllerDefPtr def, virDomainControllerModelTypeFromString(const virDomainControllerDef *def,
const char *model) const char *model)
{ {
if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI) if (def->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI)
...@@ -7380,7 +7380,7 @@ error: ...@@ -7380,7 +7380,7 @@ error:
* *
*/ */
static virDomainTPMDefPtr static virDomainTPMDefPtr
virDomainTPMDefParseXML(const xmlNodePtr node, virDomainTPMDefParseXML(xmlNodePtr node,
xmlXPathContextPtr ctxt, xmlXPathContextPtr ctxt,
unsigned int flags) unsigned int flags)
{ {
...@@ -7605,7 +7605,7 @@ error: ...@@ -7605,7 +7605,7 @@ error:
/* Parse the XML definition for a clock timer */ /* Parse the XML definition for a clock timer */
static virDomainTimerDefPtr static virDomainTimerDefPtr
virDomainTimerDefParseXML(const xmlNodePtr node, virDomainTimerDefParseXML(xmlNodePtr node,
xmlXPathContextPtr ctxt) xmlXPathContextPtr ctxt)
{ {
char *name = NULL; char *name = NULL;
...@@ -8405,7 +8405,7 @@ error: ...@@ -8405,7 +8405,7 @@ error:
static virDomainSoundCodecDefPtr static virDomainSoundCodecDefPtr
virDomainSoundCodecDefParseXML(const xmlNodePtr node) virDomainSoundCodecDefParseXML(xmlNodePtr node)
{ {
char *type; char *type;
virDomainSoundCodecDefPtr def; virDomainSoundCodecDefPtr def;
...@@ -8433,7 +8433,7 @@ error: ...@@ -8433,7 +8433,7 @@ error:
static virDomainSoundDefPtr static virDomainSoundDefPtr
virDomainSoundDefParseXML(const xmlNodePtr node, virDomainSoundDefParseXML(xmlNodePtr node,
xmlXPathContextPtr ctxt, xmlXPathContextPtr ctxt,
unsigned int flags) unsigned int flags)
{ {
...@@ -8502,7 +8502,7 @@ error: ...@@ -8502,7 +8502,7 @@ error:
static virDomainWatchdogDefPtr static virDomainWatchdogDefPtr
virDomainWatchdogDefParseXML(const xmlNodePtr node, virDomainWatchdogDefParseXML(xmlNodePtr node,
unsigned int flags) unsigned int flags)
{ {
...@@ -8555,7 +8555,7 @@ error: ...@@ -8555,7 +8555,7 @@ error:
static virDomainRNGDefPtr static virDomainRNGDefPtr
virDomainRNGDefParseXML(const xmlNodePtr node, virDomainRNGDefParseXML(xmlNodePtr node,
xmlXPathContextPtr ctxt, xmlXPathContextPtr ctxt,
unsigned int flags) unsigned int flags)
{ {
...@@ -8676,7 +8676,7 @@ error: ...@@ -8676,7 +8676,7 @@ error:
static virDomainMemballoonDefPtr static virDomainMemballoonDefPtr
virDomainMemballoonDefParseXML(const xmlNodePtr node, virDomainMemballoonDefParseXML(xmlNodePtr node,
xmlXPathContextPtr ctxt, xmlXPathContextPtr ctxt,
unsigned int flags) unsigned int flags)
{ {
...@@ -8723,7 +8723,7 @@ error: ...@@ -8723,7 +8723,7 @@ error:
} }
static virDomainNVRAMDefPtr static virDomainNVRAMDefPtr
virDomainNVRAMDefParseXML(const xmlNodePtr node, virDomainNVRAMDefParseXML(xmlNodePtr node,
unsigned int flags) unsigned int flags)
{ {
virDomainNVRAMDefPtr def; virDomainNVRAMDefPtr def;
...@@ -8742,7 +8742,7 @@ error: ...@@ -8742,7 +8742,7 @@ error:
} }
static virSysinfoDefPtr static virSysinfoDefPtr
virSysinfoParseXML(const xmlNodePtr node, virSysinfoParseXML(xmlNodePtr node,
xmlXPathContextPtr ctxt, xmlXPathContextPtr ctxt,
unsigned char *domUUID, unsigned char *domUUID,
bool uuid_generated) bool uuid_generated)
...@@ -8859,7 +8859,7 @@ error: ...@@ -8859,7 +8859,7 @@ error:
} }
int int
virDomainVideoDefaultRAM(virDomainDefPtr def, virDomainVideoDefaultRAM(const virDomainDef *def,
int type) int type)
{ {
switch (type) { switch (type) {
...@@ -8890,7 +8890,7 @@ virDomainVideoDefaultRAM(virDomainDefPtr def, ...@@ -8890,7 +8890,7 @@ virDomainVideoDefaultRAM(virDomainDefPtr def,
int int
virDomainVideoDefaultType(virDomainDefPtr def) virDomainVideoDefaultType(const virDomainDef *def)
{ {
switch (def->virtType) { switch (def->virtType) {
case VIR_DOMAIN_VIRT_TEST: case VIR_DOMAIN_VIRT_TEST:
...@@ -8919,7 +8919,8 @@ virDomainVideoDefaultType(virDomainDefPtr def) ...@@ -8919,7 +8919,8 @@ virDomainVideoDefaultType(virDomainDefPtr def)
} }
static virDomainVideoAccelDefPtr static virDomainVideoAccelDefPtr
virDomainVideoAccelDefParseXML(const xmlNodePtr node) { virDomainVideoAccelDefParseXML(xmlNodePtr node)
{
xmlNodePtr cur; xmlNodePtr cur;
virDomainVideoAccelDefPtr def; virDomainVideoAccelDefPtr def;
char *support3d = NULL; char *support3d = NULL;
...@@ -8963,8 +8964,8 @@ virDomainVideoAccelDefParseXML(const xmlNodePtr node) { ...@@ -8963,8 +8964,8 @@ virDomainVideoAccelDefParseXML(const xmlNodePtr node) {
} }
static virDomainVideoDefPtr static virDomainVideoDefPtr
virDomainVideoDefParseXML(const xmlNodePtr node, virDomainVideoDefParseXML(xmlNodePtr node,
virDomainDefPtr dom, const virDomainDef *dom,
unsigned int flags) unsigned int flags)
{ {
virDomainVideoDefPtr def; virDomainVideoDefPtr def;
...@@ -9070,8 +9071,8 @@ error: ...@@ -9070,8 +9071,8 @@ error:
static virDomainHostdevDefPtr static virDomainHostdevDefPtr
virDomainHostdevDefParseXML(virDomainXMLOptionPtr xmlopt, virDomainHostdevDefParseXML(virDomainXMLOptionPtr xmlopt,
virDomainDefPtr vmdef, const virDomainDef *vmdef,
const xmlNodePtr node, xmlNodePtr node,
xmlXPathContextPtr ctxt, xmlXPathContextPtr ctxt,
virHashTablePtr bootHash, virHashTablePtr bootHash,
unsigned int flags) unsigned int flags)
...@@ -9161,7 +9162,7 @@ error: ...@@ -9161,7 +9162,7 @@ error:
static virDomainRedirdevDefPtr static virDomainRedirdevDefPtr
virDomainRedirdevDefParseXML(const xmlNodePtr node, virDomainRedirdevDefParseXML(xmlNodePtr node,
virHashTablePtr bootHash, virHashTablePtr bootHash,
unsigned int flags) unsigned int flags)
{ {
...@@ -9298,7 +9299,7 @@ cleanup: ...@@ -9298,7 +9299,7 @@ cleanup:
} }
static virDomainRedirFilterUsbDevDefPtr static virDomainRedirFilterUsbDevDefPtr
virDomainRedirFilterUsbDevDefParseXML(const xmlNodePtr node) virDomainRedirFilterUsbDevDefParseXML(xmlNodePtr node)
{ {
char *class; char *class;
char *vendor = NULL, *product = NULL; char *vendor = NULL, *product = NULL;
...@@ -9389,7 +9390,7 @@ error: ...@@ -9389,7 +9390,7 @@ error:
} }
static virDomainRedirFilterDefPtr static virDomainRedirFilterDefPtr
virDomainRedirFilterDefParseXML(const xmlNodePtr node, virDomainRedirFilterDefParseXML(xmlNodePtr node,
xmlXPathContextPtr ctxt) xmlXPathContextPtr ctxt)
{ {
int n; int n;
...@@ -9476,7 +9477,7 @@ virDomainPMStateParseXML(xmlXPathContextPtr ctxt, ...@@ -9476,7 +9477,7 @@ virDomainPMStateParseXML(xmlXPathContextPtr ctxt,
virDomainDeviceDefPtr virDomainDeviceDefPtr
virDomainDeviceDefParse(const char *xmlStr, virDomainDeviceDefParse(const char *xmlStr,
virDomainDefPtr def, const virDomainDef *def,
virCapsPtr caps, virCapsPtr caps,
virDomainXMLOptionPtr xmlopt, virDomainXMLOptionPtr xmlopt,
unsigned int flags) unsigned int flags)
...@@ -10329,6 +10330,7 @@ virDomainChrGetDomainPtrsInternal(virDomainDefPtr vmdef, ...@@ -10329,6 +10330,7 @@ virDomainChrGetDomainPtrsInternal(virDomainDefPtr vmdef,
} }
} }
/* Return the array within vmdef that can contain a chrdefptr of the /* Return the array within vmdef that can contain a chrdefptr of the
* given type. */ * given type. */
void void
...@@ -10352,6 +10354,7 @@ virDomainChrGetDomainPtrs(const virDomainDef *vmdef, ...@@ -10352,6 +10354,7 @@ virDomainChrGetDomainPtrs(const virDomainDef *vmdef,
} }
} }
int int
virDomainChrInsert(virDomainDefPtr vmdef, virDomainChrInsert(virDomainDefPtr vmdef,
virDomainChrDefPtr chr) virDomainChrDefPtr chr)
...@@ -10530,8 +10533,8 @@ cleanup: ...@@ -10530,8 +10533,8 @@ cleanup:
static int virDomainIdMapEntrySort(const void *a, const void *b) static int virDomainIdMapEntrySort(const void *a, const void *b)
{ {
const virDomainIdMapEntryPtr entrya = (const virDomainIdMapEntryPtr) a; const virDomainIdMapEntry *entrya = a;
const virDomainIdMapEntryPtr entryb = (const virDomainIdMapEntryPtr) b; const virDomainIdMapEntry *entryb = b;
if (entrya->start > entryb->start) if (entrya->start > entryb->start)
return 1; return 1;
...@@ -10550,7 +10553,7 @@ static int virDomainIdMapEntrySort(const void *a, const void *b) ...@@ -10550,7 +10553,7 @@ static int virDomainIdMapEntrySort(const void *a, const void *b)
*/ */
static virDomainIdMapEntryPtr static virDomainIdMapEntryPtr
virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt, virDomainIdmapDefParseXML(xmlXPathContextPtr ctxt,
const xmlNodePtr *node, xmlNodePtr *node,
size_t num) size_t num)
{ {
size_t i; size_t i;
...@@ -10601,7 +10604,7 @@ cleanup: ...@@ -10601,7 +10604,7 @@ cleanup:
* have to check the returned cpuid for validity. * have to check the returned cpuid for validity.
*/ */
static virDomainVcpuPinDefPtr static virDomainVcpuPinDefPtr
virDomainVcpuPinDefParseXML(const xmlNodePtr node, virDomainVcpuPinDefParseXML(xmlNodePtr node,
xmlXPathContextPtr ctxt, xmlXPathContextPtr ctxt,
int maxvcpus, int maxvcpus,
int emulator) int emulator)
...@@ -17434,9 +17437,10 @@ char ...@@ -17434,9 +17437,10 @@ char
* @return 0 on success, -1 on failure * @return 0 on success, -1 on failure
*/ */
int int
virDiskNameToBusDeviceIndex(const virDomainDiskDefPtr disk, virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk,
int *busIdx, int *busIdx,
int *devIdx) { int *devIdx)
{
int idx = virDiskNameToIndex(disk->dst); int idx = virDiskNameToIndex(disk->dst);
if (idx < 0) if (idx < 0)
...@@ -18242,7 +18246,7 @@ virDomainNetFind(virDomainDefPtr def, const char *device) ...@@ -18242,7 +18246,7 @@ virDomainNetFind(virDomainDefPtr def, const char *device)
*/ */
virDomainDeviceDefPtr virDomainDeviceDefPtr
virDomainDeviceDefCopy(virDomainDeviceDefPtr src, virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
const virDomainDefPtr def, const virDomainDef *def,
virCapsPtr caps, virCapsPtr caps,
virDomainXMLOptionPtr xmlopt) virDomainXMLOptionPtr xmlopt)
{ {
......
...@@ -2130,11 +2130,15 @@ typedef void (*virDomainXMLPrivateDataFreeFunc)(void *); ...@@ -2130,11 +2130,15 @@ typedef void (*virDomainXMLPrivateDataFreeFunc)(void *);
typedef int (*virDomainXMLPrivateDataFormatFunc)(virBufferPtr, void *); typedef int (*virDomainXMLPrivateDataFormatFunc)(virBufferPtr, void *);
typedef int (*virDomainXMLPrivateDataParseFunc)(xmlXPathContextPtr, void *); typedef int (*virDomainXMLPrivateDataParseFunc)(xmlXPathContextPtr, void *);
/* Called once after everything else has been parsed, for adjusting
* overall domain defaults. */
typedef int (*virDomainDefPostParseCallback)(virDomainDefPtr def, typedef int (*virDomainDefPostParseCallback)(virDomainDefPtr def,
virCapsPtr caps, virCapsPtr caps,
void *opaque); void *opaque);
/* Called once per device, for adjusting per-device settings while
* leaving the overall domain otherwise unchanged. */
typedef int (*virDomainDeviceDefPostParseCallback)(virDomainDeviceDefPtr dev, typedef int (*virDomainDeviceDefPostParseCallback)(virDomainDeviceDefPtr dev,
virDomainDefPtr def, const virDomainDef *def,
virCapsPtr caps, virCapsPtr caps,
void *opaque); void *opaque);
...@@ -2189,11 +2193,11 @@ virDomainObjPtr virDomainObjNew(virDomainXMLOptionPtr caps) ...@@ -2189,11 +2193,11 @@ virDomainObjPtr virDomainObjNew(virDomainXMLOptionPtr caps)
virDomainObjListPtr virDomainObjListNew(void); virDomainObjListPtr virDomainObjListNew(void);
virDomainObjPtr virDomainObjListFindByID(const virDomainObjListPtr doms, virDomainObjPtr virDomainObjListFindByID(virDomainObjListPtr doms,
int id); int id);
virDomainObjPtr virDomainObjListFindByUUID(const virDomainObjListPtr doms, virDomainObjPtr virDomainObjListFindByUUID(virDomainObjListPtr doms,
const unsigned char *uuid); const unsigned char *uuid);
virDomainObjPtr virDomainObjListFindByName(const virDomainObjListPtr doms, virDomainObjPtr virDomainObjListFindByName(virDomainObjListPtr doms,
const char *name); const char *name);
bool virDomainObjTaint(virDomainObjPtr obj, bool virDomainObjTaint(virDomainObjPtr obj,
...@@ -2234,7 +2238,7 @@ void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def); ...@@ -2234,7 +2238,7 @@ void virDomainRedirdevDefFree(virDomainRedirdevDefPtr def);
void virDomainRedirFilterDefFree(virDomainRedirFilterDefPtr def); void virDomainRedirFilterDefFree(virDomainRedirFilterDefPtr def);
void virDomainDeviceDefFree(virDomainDeviceDefPtr def); void virDomainDeviceDefFree(virDomainDeviceDefPtr def);
virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomainDeviceDefPtr src, virDomainDeviceDefPtr virDomainDeviceDefCopy(virDomainDeviceDefPtr src,
const virDomainDefPtr def, const virDomainDef *def,
virCapsPtr caps, virCapsPtr caps,
virDomainXMLOptionPtr xmlopt); virDomainXMLOptionPtr xmlopt);
int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info, int virDomainDeviceAddressIsValid(virDomainDeviceInfoPtr info,
...@@ -2269,12 +2273,12 @@ enum { ...@@ -2269,12 +2273,12 @@ enum {
VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE = (1 << 1), VIR_DOMAIN_OBJ_LIST_ADD_CHECK_LIVE = (1 << 1),
}; };
virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms, virDomainObjPtr virDomainObjListAdd(virDomainObjListPtr doms,
const virDomainDefPtr def, virDomainDefPtr def,
virDomainXMLOptionPtr xmlopt, virDomainXMLOptionPtr xmlopt,
unsigned int flags, unsigned int flags,
virDomainDefPtr *oldDef); virDomainDefPtr *oldDef);
void virDomainObjAssignDef(virDomainObjPtr domain, void virDomainObjAssignDef(virDomainObjPtr domain,
const virDomainDefPtr def, virDomainDefPtr def,
bool live, bool live,
virDomainDefPtr *oldDef); virDomainDefPtr *oldDef);
int virDomainObjSetDefTransient(virCapsPtr caps, int virDomainObjSetDefTransient(virCapsPtr caps,
...@@ -2307,7 +2311,7 @@ void virDomainObjListRemoveLocked(virDomainObjListPtr doms, ...@@ -2307,7 +2311,7 @@ void virDomainObjListRemoveLocked(virDomainObjListPtr doms,
virDomainObjPtr dom); virDomainObjPtr dom);
virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr, virDomainDeviceDefPtr virDomainDeviceDefParse(const char *xmlStr,
virDomainDefPtr def, const virDomainDef *def,
virCapsPtr caps, virCapsPtr caps,
virDomainXMLOptionPtr xmlopt, virDomainXMLOptionPtr xmlopt,
unsigned int flags); unsigned int flags);
...@@ -2494,8 +2498,8 @@ int virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk, ...@@ -2494,8 +2498,8 @@ int virDiskNameToBusDeviceIndex(virDomainDiskDefPtr disk,
virDomainFSDefPtr virDomainGetRootFilesystem(virDomainDefPtr def); virDomainFSDefPtr virDomainGetRootFilesystem(virDomainDefPtr def);
int virDomainFSIndexByName(virDomainDefPtr def, const char *name); int virDomainFSIndexByName(virDomainDefPtr def, const char *name);
int virDomainVideoDefaultType(virDomainDefPtr def); int virDomainVideoDefaultType(const virDomainDef *def);
int virDomainVideoDefaultRAM(virDomainDefPtr def, int type); int virDomainVideoDefaultRAM(const virDomainDef *def, int type);
int virDomainObjListNumOfDomains(virDomainObjListPtr doms, int virDomainObjListNumOfDomains(virDomainObjListPtr doms,
bool active, bool active,
......
...@@ -383,7 +383,7 @@ virDomainXMLPrivateDataCallbacks libxlDomainXMLPrivateDataCallbacks = { ...@@ -383,7 +383,7 @@ virDomainXMLPrivateDataCallbacks libxlDomainXMLPrivateDataCallbacks = {
static int static int
libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, libxlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
virDomainDefPtr def, const virDomainDef *def,
virCapsPtr caps ATTRIBUTE_UNUSED, virCapsPtr caps ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED) void *opaque ATTRIBUTE_UNUSED)
{ {
......
/* /*
* Copyright (C) 2010-2012 Red Hat, Inc. * Copyright (C) 2010-2013 Red Hat, Inc.
* Copyright IBM Corp. 2008 * Copyright IBM Corp. 2008
* *
* lxc_domain.h: LXC domain helpers * lxc_domain.h: LXC domain helpers
...@@ -98,7 +98,7 @@ virLXCDomainDefPostParse(virDomainDefPtr def, ...@@ -98,7 +98,7 @@ virLXCDomainDefPostParse(virDomainDefPtr def,
static int static int
virLXCDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, virLXCDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
virDomainDefPtr def ATTRIBUTE_UNUSED, const virDomainDef *def ATTRIBUTE_UNUSED,
virCapsPtr caps ATTRIBUTE_UNUSED, virCapsPtr caps ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED) void *opaque ATTRIBUTE_UNUSED)
{ {
......
...@@ -102,7 +102,7 @@ openvzDomainDefPostParse(virDomainDefPtr def, ...@@ -102,7 +102,7 @@ openvzDomainDefPostParse(virDomainDefPtr def,
static int static int
openvzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, openvzDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
virDomainDefPtr def ATTRIBUTE_UNUSED, const virDomainDef *def ATTRIBUTE_UNUSED,
virCapsPtr caps ATTRIBUTE_UNUSED, virCapsPtr caps ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED) void *opaque ATTRIBUTE_UNUSED)
{ {
......
...@@ -787,7 +787,8 @@ qemuDomainDefPostParse(virDomainDefPtr def, ...@@ -787,7 +787,8 @@ qemuDomainDefPostParse(virDomainDefPtr def,
} }
static const char * static const char *
qemuDomainDefaultNetModel(virDomainDefPtr def) { qemuDomainDefaultNetModel(const virDomainDef *def)
{
if (def->os.arch == VIR_ARCH_S390 || if (def->os.arch == VIR_ARCH_S390 ||
def->os.arch == VIR_ARCH_S390X) def->os.arch == VIR_ARCH_S390X)
return "virtio"; return "virtio";
...@@ -806,7 +807,7 @@ qemuDomainDefaultNetModel(virDomainDefPtr def) { ...@@ -806,7 +807,7 @@ qemuDomainDefaultNetModel(virDomainDefPtr def) {
static int static int
qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
virDomainDefPtr def, const virDomainDef *def,
virCapsPtr caps ATTRIBUTE_UNUSED, virCapsPtr caps ATTRIBUTE_UNUSED,
void *opaque) void *opaque)
{ {
......
...@@ -419,9 +419,9 @@ cleanup: ...@@ -419,9 +419,9 @@ cleanup:
static int static int
umlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, umlDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
virDomainDefPtr def ATTRIBUTE_UNUSED, const virDomainDef *def ATTRIBUTE_UNUSED,
virCapsPtr caps ATTRIBUTE_UNUSED, virCapsPtr caps ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED) void *opaque ATTRIBUTE_UNUSED)
{ {
if (dev->type == VIR_DOMAIN_DEVICE_CHR && if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
......
...@@ -330,7 +330,7 @@ xenUnifiedXendProbe(void) ...@@ -330,7 +330,7 @@ xenUnifiedXendProbe(void)
static int static int
xenDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, xenDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
virDomainDefPtr def, const virDomainDef *def,
virCapsPtr caps ATTRIBUTE_UNUSED, virCapsPtr caps ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED) void *opaque ATTRIBUTE_UNUSED)
{ {
...@@ -340,6 +340,15 @@ xenDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, ...@@ -340,6 +340,15 @@ xenDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
STRNEQ(def->os.type, "hvm")) STRNEQ(def->os.type, "hvm"))
dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN; dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_XEN;
return 0;
}
static int
xenDomainDefPostParse(virDomainDefPtr def,
virCapsPtr caps ATTRIBUTE_UNUSED,
void *opaque ATTRIBUTE_UNUSED)
{
if (!def->memballoon) { if (!def->memballoon) {
virDomainMemballoonDefPtr memballoon; virDomainMemballoonDefPtr memballoon;
if (VIR_ALLOC(memballoon) < 0) if (VIR_ALLOC(memballoon) < 0)
...@@ -356,6 +365,7 @@ xenDomainDeviceDefPostParse(virDomainDeviceDefPtr dev, ...@@ -356,6 +365,7 @@ xenDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
virDomainDefParserConfig xenDomainDefParserConfig = { virDomainDefParserConfig xenDomainDefParserConfig = {
.macPrefix = { 0x00, 0x16, 0x3e }, .macPrefix = { 0x00, 0x16, 0x3e },
.devicesPostParseCallback = xenDomainDeviceDefPostParse, .devicesPostParseCallback = xenDomainDeviceDefPostParse,
.domainPostParseCallback = xenDomainDefPostParse,
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册