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

View File

@ -33,6 +33,11 @@
#include "util.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 */
/* NB: Keep in sync with virDomainVirtTypeToString impl */
enum virDomainVirtType {

View File

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

View File

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