Add internal XML parsing/formatting flag

We need to store things like device names and PCI slot numbers in the
qemu domain state file so that we don't lose that information on
libvirtd restart. Add a flag to indicate that this information should
be parsed or formatted.

Make bit 16 and above of the flags bitmask for internal use only and
consume the first bit for this new status flag.

* include/libvirt/libvirt.h: add VIR_DOMAIN_XML_FLAGS_MASK

* src/libvirt.c: reject private flags in virDomainGetXMLDesc()

* src/domain_conf.h: add VIR_DOMAIN_XML_INTERNAL_STATUS

* src/domain_conf.c: pass the flag from virDomainObjParseXML() and
  virDomainSaveStatus
This commit is contained in:
Mark McLoughlin 2009-07-17 22:08:33 +01:00
parent 1499e1d5f4
commit aa98871c77
4 changed files with 13 additions and 4 deletions

View File

@ -2896,7 +2896,8 @@ static virDomainObjPtr virDomainObjParseXML(virConnectPtr conn,
oldnode = ctxt->node; oldnode = ctxt->node;
ctxt->node = config; ctxt->node = config;
obj->def = virDomainDefParseXML(conn, caps, ctxt, 0); obj->def = virDomainDefParseXML(conn, caps, ctxt,
VIR_DOMAIN_XML_INTERNAL_STATUS);
ctxt->node = oldnode; ctxt->node = oldnode;
if (!obj->def) if (!obj->def)
goto error; goto error;
@ -4277,12 +4278,11 @@ int virDomainSaveStatus(virConnectPtr conn,
const char *statusDir, const char *statusDir,
virDomainObjPtr obj) virDomainObjPtr obj)
{ {
int flags = VIR_DOMAIN_XML_SECURE|VIR_DOMAIN_XML_INTERNAL_STATUS;
int ret = -1; int ret = -1;
char *xml; char *xml;
if (!(xml = virDomainObjFormat(conn, if (!(xml = virDomainObjFormat(conn, obj, flags)))
obj,
VIR_DOMAIN_XML_SECURE)))
goto cleanup; goto cleanup;
if (virDomainSaveXML(conn, statusDir, obj->def, xml)) if (virDomainSaveXML(conn, statusDir, obj->def, xml))

View File

@ -33,6 +33,11 @@
#include "util.h" #include "util.h"
#include "threads.h" #include "threads.h"
/* Private component of virDomainXMLFlags */
typedef enum {
VIR_DOMAIN_XML_INTERNAL_STATUS = (1<<16), /* dump internal domain status information */
} virDomainXMLInternalFlags;
/* Different types of hypervisor */ /* Different types of hypervisor */
/* NB: Keep in sync with virDomainVirtTypeToString impl */ /* NB: Keep in sync with virDomainVirtTypeToString impl */
enum virDomainVirtType { enum virDomainVirtType {

View File

@ -2726,6 +2726,8 @@ virDomainGetXMLDesc(virDomainPtr domain, int flags)
goto error; goto error;
} }
flags &= VIR_DOMAIN_XML_FLAGS_MASK;
if (conn->driver->domainDumpXML) { if (conn->driver->domainDumpXML) {
char *ret; char *ret;
ret = conn->driver->domainDumpXML (domain, flags); ret = conn->driver->domainDumpXML (domain, flags);

View File

@ -24,6 +24,8 @@
#include "internal.h" #include "internal.h"
/* bits 16 and above of virDomainXMLFlags are for internal use */
#define VIR_DOMAIN_XML_FLAGS_MASK 0xffff
#ifdef WITH_LIBVIRTD #ifdef WITH_LIBVIRTD
int virStateInitialize(int privileged); int virStateInitialize(int privileged);