[libvirt] PATCH: 0/3: Run QEMU guests within a CGroup
by Daniel P. Berrange
Recent Linux kernels have a new concept of 'CGroups' which is a way to
group tasks on the system and apply policy to them as a whole. We already
use this in the LXC container driver, to control total memory usage of
things runing within a container.
This patch series is a proof of concept to make use of CGroups in the
QEMU driver. The idea is that we have a 3 level cgroup hierarchy
- Top level; contains the libvirtd daemon itself
- 2nd level: one per libvirt driver, but dos not contain any
processes.
- 3rd level: one per guest VM. Contains the QEMU process
The host admin can do control on the top level and 2nd level to set an
overall system policy. libvirt will then provide APIs / capabilities to
control individual VMs policy.
Daniel
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
15 years, 5 months
[libvirt] [RFC][PATCH] lxc: drop CAP_SYS_BOOT capability to prevent rebooting from inside containers
by Ryota Ozaki
Hi,
Current lxc driver unexpectedly allows users inside containers to reboot
host physical machine. This patch prevents this by dropping CAP_SYS_BOOT
capability in the bounding set of the init processes in every containers.
Note that the patch intends to make it easy to add further capabilities
to drop if needed, although I'm not sure which capabilities should be
dropped. (We might need to drop CAP_SETFCAP as well to be strict...)
Thanks,
ozaki-r
Signed-off-by: Ryota Ozaki <ozaki.ryota(a)gmail.com>
>From 0e7a7622bc6411bbe76c05c63c6e6e61d379d97b Mon Sep 17 00:00:00 2001
From: Ryota Ozaki <ozaki.ryota(a)gmail.com>
Date: Fri, 8 May 2009 04:29:24 +0900
Subject: [PATCH] lxc: drop CAP_SYS_BOOT capability to prevent
rebooting from inside containers
Current lxc driver unexpectedly allows users inside containers to reboot
host physical machine. This patch prevents this by dropping CAP_SYS_BOOT
capability in the bounding set of the init processes in every containers.
---
src/lxc_container.c | 30 ++++++++++++++++++++++++++++++
1 files changed, 30 insertions(+), 0 deletions(-)
diff --git a/src/lxc_container.c b/src/lxc_container.c
index 3946b84..37ab216 100644
--- a/src/lxc_container.c
+++ b/src/lxc_container.c
@@ -32,6 +32,8 @@
#include <sys/ioctl.h>
#include <sys/mount.h>
#include <sys/wait.h>
+#include <sys/prctl.h>
+#include <sys/capability.h>
#include <unistd.h>
#include <mntent.h>
@@ -639,6 +641,30 @@ static int lxcContainerSetupMounts(virDomainDefPtr vmDef,
return lxcContainerSetupExtraMounts(vmDef);
}
+
+static int lxcContainerDropCapabilities( virDomainDefPtr vmDef )
+{
+ int i;
+ const struct {
+ int id;
+ const char *name;
+ } caps[] = {
+#define ID_STRING(name) name, #name
+ { ID_STRING(CAP_SYS_BOOT) },
+ };
+
+ for (i = 0 ; i < ARRAY_CARDINALITY(caps) ; i++) {
+ if (prctl(PR_CAPBSET_DROP, caps[i].id, 0, 0, 0)) {
+ lxcError(NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("failed to drop %s"), caps[i].name);
+ return -1;
+ }
+ }
+
+ return 0;
+}
+
+
/**
* lxcChild:
* @argv: Pointer to container arguments
@@ -705,6 +731,10 @@ static int lxcContainerChild( void *data )
if (lxcContainerEnableInterfaces(argv->nveths, argv->veths) < 0)
return -1;
+ /* drop a set of root capabilities */
+ if (lxcContainerDropCapabilities(vmDef) < 0)
+ return -1;
+
/* this function will only return if an error occured */
return lxcContainerExecInit(vmDef);
}
--
1.6.0.6
15 years, 6 months
[Libvirt] SSH with certificates
by Christian Weyermann
Hello everybody,
We are trying to use libvirt with qemu over ssh and our goal is to have
authentication done by certificates. Therefore I created a keypair on
the client and send the public key to the server. Std. SSH connections
work without an password prompt as expected (ssh <ip> -l user), but if I
try "sudo virsh -c qemu+ssh://user@<ip>/system" it prompts for a
password (Beside that password prompt it works as expected).
Is there anything else I have to do beside registering the public key at
the server?
Thanks for your help and best regards,
Christian
15 years, 6 months
[libvirt] Release of libvirt-0.6.4
by Daniel Veillard
The monthly release is out !
There is a number of new things in that release, but as happens in
time-based releases some are not fully complete, for example the
OpenNebula driver was added but it still need a bit of work on the
detection code and a bit of cleanup to avoid a GPL/AFS licencing
issue, so please don't enable it except for test builds. We also
have a new set of Interface config APIs but they are not yet
implemented by a driver and the XML import/export routines are not
there yet. Still there is a lot of things to use and discover in this
release as you can see below:
* New features:
- new API virStorageVolCreateXMLFrom (Cole Robinson)
- full VBox graphic capabilities (Pritesh Kothari)
- Interface config APIs (Laine Stump)
- APIs for domain XML conversions (Daniel Berrange)
- initial version of OpenNebula driver (Abel Miguez Rodriguez)
* Portability:
- better compiler warning selection (Daniel Berrange)
- Win32 portability fixes (Daniel Berrange)
* Documentation:
- documentation for <sound> device XML format (Cole Robinson)
- storage format documentation fixes (Ryota Ozaki)
- docs for XML conversion APIs (Daniel Berrange)
- inconsistencies in storage volume docs and schemas (Ryota Ozaki)
* Bug fixes:
- fix hostdev managed handling (Mark McLoughlin)
- lxc_controller should not cash without args (Guido Gunther)
- bug fixes in I/O routines (Guido Gunther)
- fix migrationsave/restore for QEmu 0.10.0 (Daniel Berrange)
- avoid crash on VBox init (Guido Gunther)
- fix dev and cgroup init in LXC (Ryota Ozaki)
- QEmu startup fix (Cole Robinson)
- block node reboots from LXCs (Ryota Ozaki)
- QEmu argv detection fix for recent kvm (Daniel Berrange)
- fix watch/timer event deletion (Daniel Berrange)
- fix XML escaping bug
- various locking bugs (Daniel Berrange)
- avoid a deadlock in HAL nodedev driver (Cole Robinson)
- detection of node device media insert/eject (Cole Robinson)
- broken networking with new QEMU/KVM >= 86 (Daniel Berrange)
- various fixes in domain and network startup error report (Cole
Robinson)
- double free on unexpected client disconnect (Daniel Berrange)
* Improvements:
- cleanups and doc on virExec (Cole Robinson)
- error reporting in QEmu migrations (Cole Robinson)
- better path and driver detection in VBox (Pritesh Kothari)
- avoid caching QEMU driver capabilities(Cole Robinson)
- multiple graphics elements definitions (Pritesh Kothari)
- LSB init header init.d improvements (Frederik Himpe)
- special erro code for invalid operations (Daniel Berrange)
- dlopen error logging (Daniel Berrange)
- fix UUID and name uniqueness (Daniel Berrange)
- improvement on VBox initialization (Pritesh Kothari and Dan Berrange)
- "Host only" and "Internal" network in VBox (Pritesh Kothari)
- add utility virExecDaemonize (Cole Robinson)
- enable bridges without IP (Ludwig Nussel)
- 'make -s' silencing (Daniel Berrange)
- test case for exercising the event loop (Daniel Berrange)
- virsh commands vol-clone and vol-create-from (Cole Robinson)
- new xend don't use [] around cpumaps (Tatsuro Enokura)
- add the CIL mutex lock checker (Daniel Berrange)
- fix some LXC error code (Amy Griffis)
- virInterface python bindings (Daniel Berrange)
- fix to the example code for event handling (Pritesh Kothari)
- always add location informations to logging (Daniel Berrange)
- python domain events example and binding (Daniel Berrange)
- PPC Qemu Machine Type update (Thomas Baker)
* Cleanups:
- strings bug in virsh (Daniel Berrange)
- various cleanups in storage code (Cole Robinson)
- rpm spec cleanups
- destructors data cleanups (Laine Stump)
- some QEmu code refactoring (Daniel Berrange)
- avoid dependancy on libcap (Daniel Berrange)
- python import cleanup (Cole Robinson)
- virAsprintf based cleanups in storage code (Cole Robinson)
- fix some direct stderr logging
- OpenNebula driver cleanups (Daniel Berrange)
Thanks everybody for the contributions for this new release !
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel(a)veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
15 years, 6 months
[libvirt] PATCH: Fix redetection of transient QEMU VMs on daemon restarts
by Daniel P. Berrange
When the libvirtd daemon starts up, it reads all config files from
/etc/libvirt/qemu. For each config file loaded, it then probes for
a pidfile / live status XML config in /var/run/libvirt/qemu.
In retrospect there is an obvious problem with this approach: it misses
all transient VMs which don't ever have config files in /etc/libvirt/qemu.
The core goal of this patch, is thus to change the way we deal with startup
to apply the following logic.
- Scan & load all status files in /var/run/libvirt/qemu for running VMs
- Reconnect to the monitor for all VMs, and re-detect VCPU threads.
- Scan & load all inactive configs in /etc/libvirt/qemu
This ensures we always re-detect all inactive and running VMs, whether
transient or persistent.
It also fixes two other bugs, first we forgot to detect VCPU threads,
so vCPU affinity functions were broken, and it also re-reserves the MCS
category with selinux so it is not re-used later.
Finally, if the attempt to reconnect to the QEMU monitor for a running
VM fails, then we explicitly kill off that VM, rather than just ignoring
it. This avoids leaving orphaned QEMU processes.
The patch is larger than anticipated, because I moved all the status
file code out of QEMU driver into the generic domain_conf.c file. This
enables both scanning loops to be done via the single method
virDomainLoadAllConfigs, just by pasing different directories. I also
want to re-use this code in the LXC and UML drivers to improve bugs in
their logic
domain_conf.c | 314 ++++++++++++++++++++++++++++++++++++++++++++++-----
domain_conf.h | 17 ++
libvirt_private.syms | 1
lxc_driver.c | 2
qemu_conf.c | 190 ------------------------------
qemu_conf.h | 18 --
qemu_driver.c | 178 +++++++++++++---------------
security.h | 3
security_selinux.c | 39 ++++++
uml_driver.c | 4
10 files changed, 431 insertions(+), 335 deletions(-)
Daniel
diff --git a/src/domain_conf.c b/src/domain_conf.c
--- a/src/domain_conf.c
+++ b/src/domain_conf.c
@@ -39,6 +39,7 @@
#include "util.h"
#include "buf.h"
#include "c-ctype.h"
+#include "logging.h"
#define VIR_FROM_THIS VIR_FROM_DOMAIN
@@ -511,6 +512,31 @@ void virDomainObjListFree(virDomainObjLi
vms->count = 0;
}
+
+static virDomainObjPtr virDomainObjNew(virConnectPtr conn)
+{
+ virDomainObjPtr domain;
+
+ if (VIR_ALLOC(domain) < 0) {
+ virReportOOMError(conn);
+ return NULL;
+ }
+
+ if (virMutexInit(&domain->lock) < 0) {
+ virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("cannot initialize mutex"));
+ VIR_FREE(domain);
+ return NULL;
+ }
+
+ virDomainObjLock(domain);
+ domain->state = VIR_DOMAIN_SHUTOFF;
+ domain->monitorWatch = -1;
+ domain->monitor = -1;
+
+ return domain;
+}
+
virDomainObjPtr virDomainAssignDef(virConnectPtr conn,
virDomainObjListPtr doms,
const virDomainDefPtr def)
@@ -530,29 +556,15 @@ virDomainObjPtr virDomainAssignDef(virCo
return domain;
}
- if (VIR_ALLOC(domain) < 0) {
- virReportOOMError(conn);
- return NULL;
- }
-
- if (virMutexInit(&domain->lock) < 0) {
- virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
- "%s", _("cannot initialize mutex"));
- VIR_FREE(domain);
- return NULL;
- }
-
- virDomainObjLock(domain);
- domain->state = VIR_DOMAIN_SHUTOFF;
+ if (VIR_REALLOC_N(doms->objs, doms->count + 1) < 0) {
+ virReportOOMError(conn);
+ return NULL;
+ }
+
+ if (!(domain = virDomainObjNew(conn)))
+ return NULL;
+
domain->def = def;
- domain->monitorWatch = -1;
- domain->monitor = -1;
-
- if (VIR_REALLOC_N(doms->objs, doms->count + 1) < 0) {
- virReportOOMError(conn);
- VIR_FREE(domain);
- return NULL;
- }
doms->objs[doms->count] = domain;
doms->count++;
@@ -2621,6 +2633,68 @@ no_memory:
return NULL;
}
+
+static virDomainObjPtr virDomainObjParseXML(virConnectPtr conn,
+ virCapsPtr caps,
+ xmlXPathContextPtr ctxt)
+{
+ char *tmp = NULL;
+ long val;
+ xmlNodePtr config;
+ xmlNodePtr oldctxt;
+ virDomainObjPtr obj;
+
+ if (!(obj = virDomainObjNew(conn)))
+ return NULL;
+
+ if (!(config = virXPathNode(conn, "./domain", ctxt))) {
+ virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("no domain config"));
+ goto error;
+ }
+
+ oldctxt = ctxt->node;
+ ctxt->node = config;
+ obj->def = virDomainDefParseXML(conn, caps, ctxt, 0);
+ ctxt->node = oldctxt;
+ if (!obj->def)
+ goto error;
+
+ if (!(tmp = virXPathString(conn, "string(./@state)", ctxt))) {
+ virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("missing domain state"));
+ goto error;
+ }
+ if ((obj->state = virDomainStateTypeFromString(tmp)) < 0) {
+ virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("invalid domain state '%s'"), tmp);
+ VIR_FREE(tmp);
+ goto error;
+ }
+ VIR_FREE(tmp);
+
+ if ((virXPathLong(conn, "string(./@pid)", ctxt, &val)) < 0) {
+ virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("invalid pid"));
+ goto error;
+ }
+ obj->pid = (pid_t)val;
+
+ if(!(obj->monitorpath =
+ virXPathString(conn, "string(./monitor[1]/@path)", ctxt))) {
+ virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("no monitor path"));
+ goto error;
+ }
+
+ return obj;
+
+error:
+ virDomainObjFree(obj);
+ return NULL;
+}
+
+
/* Called from SAX on parsing errors in the XML. */
static void
catchXMLError (void *ctx, const char *msg ATTRIBUTE_UNUSED, ...)
@@ -2753,6 +2827,78 @@ cleanup:
xmlXPathFreeContext(ctxt);
return def;
}
+
+
+virDomainObjPtr virDomainObjParseFile(virConnectPtr conn,
+ virCapsPtr caps,
+ const char *filename)
+{
+ xmlParserCtxtPtr pctxt;
+ xmlDocPtr xml = NULL;
+ xmlNodePtr root;
+ virDomainObjPtr obj = NULL;
+
+ /* Set up a parser context so we can catch the details of XML errors. */
+ pctxt = xmlNewParserCtxt ();
+ if (!pctxt || !pctxt->sax)
+ goto cleanup;
+ pctxt->sax->error = catchXMLError;
+ pctxt->_private = conn;
+
+ if (conn) virResetError (&conn->err);
+ xml = xmlCtxtReadFile (pctxt, filename, NULL,
+ XML_PARSE_NOENT | XML_PARSE_NONET |
+ XML_PARSE_NOWARNING);
+ if (!xml) {
+ if (virGetLastError() == NULL)
+ virDomainReportError(conn, VIR_ERR_XML_ERROR,
+ "%s", _("failed to parse xml document"));
+ goto cleanup;
+ }
+
+ if ((root = xmlDocGetRootElement(xml)) == NULL) {
+ virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("missing root element"));
+ goto cleanup;
+ }
+
+ obj = virDomainObjParseNode(conn, caps, xml, root);
+
+cleanup:
+ xmlFreeParserCtxt (pctxt);
+ xmlFreeDoc (xml);
+ return obj;
+}
+
+
+virDomainObjPtr virDomainObjParseNode(virConnectPtr conn,
+ virCapsPtr caps,
+ xmlDocPtr xml,
+ xmlNodePtr root)
+{
+ xmlXPathContextPtr ctxt = NULL;
+ virDomainObjPtr obj = NULL;
+
+ if (!xmlStrEqual(root->name, BAD_CAST "domstatus")) {
+ virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ "%s", _("incorrect root element"));
+ goto cleanup;
+ }
+
+ ctxt = xmlXPathNewContext(xml);
+ if (ctxt == NULL) {
+ virReportOOMError(conn);
+ goto cleanup;
+ }
+
+ ctxt->node = root;
+ obj = virDomainObjParseXML(conn, caps, ctxt);
+
+cleanup:
+ xmlXPathFreeContext(ctxt);
+ return obj;
+}
+
#endif /* ! PROXY */
/************************************************************************
@@ -3704,6 +3850,33 @@ char *virDomainDefFormat(virConnectPtr c
return NULL;
}
+char *virDomainObjFormat(virConnectPtr conn,
+ virDomainObjPtr obj,
+ int flags)
+{
+ char *config_xml = NULL, *xml = NULL;
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+
+ virBufferVSprintf(&buf, "<domstatus state='%s' pid='%d'>\n",
+ virDomainStateTypeToString(obj->state),
+ obj->pid);
+ virBufferEscapeString(&buf, " <monitor path='%s'/>\n", obj->monitorpath);
+
+ if (!(config_xml = virDomainDefFormat(conn,
+ obj->def,
+ flags)))
+ goto cleanup;
+
+ virBufferAdd(&buf, config_xml, strlen(config_xml));
+ virBufferAddLit(&buf, "</domstatus>\n");
+
+ xml = virBufferContentAndReset(&buf);
+cleanup:
+ VIR_FREE(config_xml);
+ return xml;
+
+}
+
#ifndef PROXY
@@ -3779,6 +3952,27 @@ cleanup:
return ret;
}
+int virDomainSaveStatus(virConnectPtr conn,
+ const char *statusDir,
+ virDomainObjPtr obj)
+{
+ int ret = -1;
+ char *xml;
+
+ if (!(xml = virDomainObjFormat(conn,
+ obj,
+ VIR_DOMAIN_XML_SECURE)))
+ goto cleanup;
+
+ if (virDomainSaveXML(conn, statusDir, obj->def, xml))
+ goto cleanup;
+
+ ret = 0;
+cleanup:
+ VIR_FREE(xml);
+ return ret;
+}
+
virDomainObjPtr virDomainLoadConfig(virConnectPtr conn,
virCapsPtr caps,
@@ -3832,17 +4026,67 @@ error:
return NULL;
}
+static virDomainObjPtr virDomainLoadStatus(virConnectPtr conn,
+ virCapsPtr caps,
+ virDomainObjListPtr doms,
+ const char *statusDir,
+ const char *name,
+ virDomainLoadConfigNotify notify,
+ void *opaque)
+{
+ char *statusFile = NULL;
+ virDomainObjPtr obj = NULL;
+ virDomainObjPtr tmp = NULL;
+
+ if ((statusFile = virDomainConfigFile(conn, statusDir, name)) == NULL)
+ goto error;
+
+ if (!(obj = virDomainObjParseFile(conn, caps, statusFile)))
+ goto error;
+
+ tmp = virDomainFindByName(doms, obj->def->name);
+ if (tmp) {
+ virDomainObjUnlock(obj);
+ virDomainReportError(conn, VIR_ERR_INTERNAL_ERROR,
+ _("unexpected domain %s already exists"), obj->def->name);
+ goto error;
+ }
+
+ if (VIR_REALLOC_N(doms->objs, doms->count + 1) < 0) {
+ virReportOOMError(conn);
+ goto error;
+ }
+
+ doms->objs[doms->count] = obj;
+ doms->count++;
+
+ if (notify)
+ (*notify)(obj, 1, opaque);
+
+ VIR_FREE(statusFile);
+ return obj;
+
+error:
+ virDomainObjFree(obj);
+ VIR_FREE(statusFile);
+ return NULL;
+}
+
int virDomainLoadAllConfigs(virConnectPtr conn,
virCapsPtr caps,
virDomainObjListPtr doms,
const char *configDir,
const char *autostartDir,
+ int liveStatus,
virDomainLoadConfigNotify notify,
void *opaque)
{
DIR *dir;
struct dirent *entry;
+ VIR_INFO("Scanning for %s configs in %s",
+ liveStatus ? "live" : "persistent", configDir);
+
if (!(dir = opendir(configDir))) {
if (errno == ENOENT)
return 0;
@@ -3863,14 +4107,24 @@ int virDomainLoadAllConfigs(virConnectPt
/* NB: ignoring errors, so one malformed config doesn't
kill the whole process */
- dom = virDomainLoadConfig(conn,
- caps,
- doms,
- configDir,
- autostartDir,
- entry->d_name,
- notify,
- opaque);
+ VIR_INFO("Loading config file '%s.xml'", entry->d_name);
+ if (liveStatus)
+ dom = virDomainLoadStatus(conn,
+ caps,
+ doms,
+ configDir,
+ entry->d_name,
+ notify,
+ opaque);
+ else
+ dom = virDomainLoadConfig(conn,
+ caps,
+ doms,
+ configDir,
+ autostartDir,
+ entry->d_name,
+ notify,
+ opaque);
if (dom) {
virDomainObjUnlock(dom);
dom->persistent = 1;
diff --git a/src/domain_conf.h b/src/domain_conf.h
--- a/src/domain_conf.h
+++ b/src/domain_conf.h
@@ -515,7 +515,6 @@ struct _virDomainObj {
int monitor;
char *monitorpath;
int monitorWatch;
- int logfile;
int pid;
int state;
@@ -589,10 +588,22 @@ virDomainDefPtr virDomainDefParseNode(vi
xmlDocPtr doc,
xmlNodePtr root,
int flags);
+
+virDomainObjPtr virDomainObjParseFile(virConnectPtr conn,
+ virCapsPtr caps,
+ const char *filename);
+virDomainObjPtr virDomainObjParseNode(virConnectPtr conn,
+ virCapsPtr caps,
+ xmlDocPtr xml,
+ xmlNodePtr root);
+
#endif
char *virDomainDefFormat(virConnectPtr conn,
virDomainDefPtr def,
int flags);
+char *virDomainObjFormat(virConnectPtr conn,
+ virDomainObjPtr obj,
+ int flags);
int virDomainCpuSetParse(virConnectPtr conn,
const char **str,
@@ -615,6 +626,9 @@ int virDomainSaveXML(virConnectPtr conn,
int virDomainSaveConfig(virConnectPtr conn,
const char *configDir,
virDomainDefPtr def);
+int virDomainSaveStatus(virConnectPtr conn,
+ const char *statusDir,
+ virDomainObjPtr obj);
typedef void (*virDomainLoadConfigNotify)(virDomainObjPtr dom,
int newDomain,
@@ -634,6 +648,7 @@ int virDomainLoadAllConfigs(virConnectPt
virDomainObjListPtr doms,
const char *configDir,
const char *autostartDir,
+ int liveStatus,
virDomainLoadConfigNotify notify,
void *opaque);
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -94,6 +94,7 @@ virDomainObjListFree;
virDomainRemoveInactive;
virDomainSaveXML;
virDomainSaveConfig;
+virDomainSaveStatus;
virDomainSoundDefFree;
virDomainSoundModelTypeFromString;
virDomainSoundModelTypeToString;
diff --git a/src/lxc_driver.c b/src/lxc_driver.c
--- a/src/lxc_driver.c
+++ b/src/lxc_driver.c
@@ -1176,7 +1176,7 @@ static int lxcStartup(void)
&lxc_driver->domains,
lxc_driver->configDir,
lxc_driver->autostartDir,
- NULL, NULL) < 0)
+ 0, NULL, NULL) < 0)
goto cleanup;
for (i = 0 ; i < lxc_driver->domains.count ; i++) {
diff --git a/src/qemu_conf.c b/src/qemu_conf.c
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -2765,193 +2765,3 @@ cleanup:
return def;
}
-
-/* Called from SAX on parsing errors in the XML. */
-static void
-catchXMLError (void *ctx, const char *msg ATTRIBUTE_UNUSED, ...)
-{
- xmlParserCtxtPtr ctxt = (xmlParserCtxtPtr) ctx;
-
- if (ctxt) {
- virConnectPtr conn = ctxt->_private;
-
- if (ctxt->lastError.level == XML_ERR_FATAL &&
- ctxt->lastError.message != NULL) {
- qemudReportError (conn, NULL, NULL, VIR_ERR_XML_DETAIL,
- _("at line %d: %s"),
- ctxt->lastError.line,
- ctxt->lastError.message);
- }
- }
-}
-
-
-/**
- * qemudDomainStatusParseFile
- *
- * read the last known status of a domain
- *
- * Returns 0 on success
- */
-qemudDomainStatusPtr
-qemudDomainStatusParseFile(virConnectPtr conn,
- virCapsPtr caps,
- const char *filename, int flags)
-{
- xmlParserCtxtPtr pctxt = NULL;
- xmlXPathContextPtr ctxt = NULL;
- xmlDocPtr xml = NULL;
- xmlNodePtr root, config_root;
- virDomainDefPtr def = NULL;
- char *tmp = NULL;
- long val;
- qemudDomainStatusPtr status = NULL;
-
- if (VIR_ALLOC(status) < 0) {
- virReportOOMError(conn);
- goto error;
- }
-
- /* Set up a parser context so we can catch the details of XML errors. */
- pctxt = xmlNewParserCtxt ();
- if (!pctxt || !pctxt->sax)
- goto error;
- pctxt->sax->error = catchXMLError;
- pctxt->_private = conn;
-
- if (conn) virResetError (&conn->err);
- xml = xmlCtxtReadFile (pctxt, filename, NULL,
- XML_PARSE_NOENT | XML_PARSE_NONET |
- XML_PARSE_NOWARNING);
- if (!xml) {
- if (conn && conn->err.code == VIR_ERR_NONE)
- qemudReportError(conn, NULL, NULL, VIR_ERR_XML_ERROR,
- "%s", _("failed to parse xml document"));
- goto error;
- }
-
- if ((root = xmlDocGetRootElement(xml)) == NULL) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "%s", _("missing root element"));
- goto error;
- }
-
- ctxt = xmlXPathNewContext(xml);
- if (ctxt == NULL) {
- virReportOOMError(conn);
- goto error;
- }
-
- if (!xmlStrEqual(root->name, BAD_CAST "domstatus")) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "%s", _("incorrect root element"));
- goto error;
- }
-
- ctxt->node = root;
- if(!(tmp = virXPathString(conn, "string(./@state)", ctxt))) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "%s", _("invalid domain state"));
- goto error;
- } else {
- status->state = virDomainStateTypeFromString(tmp);
- VIR_FREE(tmp);
- }
-
- if((virXPathLong(conn, "string(./@pid)", ctxt, &val)) < 0) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "%s", _("invalid pid"));
- goto error;
- } else
- status->pid = (pid_t)val;
-
- if(!(tmp = virXPathString(conn, "string(./monitor[1]/@path)", ctxt))) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "%s", _("no monitor path"));
- goto error;
- } else
- status->monitorpath = tmp;
-
- if(!(config_root = virXPathNode(conn, "./domain", ctxt))) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- "%s", _("no domain config"));
- goto error;
- }
- if(!(def = virDomainDefParseNode(conn, caps, xml, config_root, flags)))
- goto error;
- else
- status->def = def;
-
-cleanup:
- xmlFreeParserCtxt (pctxt);
- xmlXPathFreeContext(ctxt);
- xmlFreeDoc (xml);
- return status;
-
-error:
- VIR_FREE(tmp);
- VIR_FREE(status);
- goto cleanup;
-}
-
-
-/**
- * qemudDomainStatusFormat
- *
- * Get the state of a running domain as XML
- *
- * Returns xml on success
- */
-static char*
-qemudDomainStatusFormat(virConnectPtr conn,
- virDomainObjPtr vm)
-{
- char *config_xml = NULL, *xml = NULL;
- virBuffer buf = VIR_BUFFER_INITIALIZER;
-
- virBufferVSprintf(&buf, "<domstatus state='%s' pid='%d'>\n",
- virDomainStateTypeToString(vm->state),
- vm->pid);
- virBufferEscapeString(&buf, " <monitor path='%s'/>\n", vm->monitorpath);
-
- if (!(config_xml = virDomainDefFormat(conn,
- vm->def,
- VIR_DOMAIN_XML_SECURE)))
- goto cleanup;
-
- virBufferAdd(&buf, config_xml, strlen(config_xml));
- virBufferAddLit(&buf, "</domstatus>\n");
-
- xml = virBufferContentAndReset(&buf);
-cleanup:
- VIR_FREE(config_xml);
- return xml;
-}
-
-
-/**
- * qemudSaveDomainStatus
- *
- * Save the current status of a running domain
- *
- * Returns 0 on success
- */
-int
-qemudSaveDomainStatus(virConnectPtr conn,
- struct qemud_driver *driver,
- virDomainObjPtr vm)
-{
- int ret = -1;
- char *xml = NULL;
-
- if (!(xml = qemudDomainStatusFormat(conn, vm)))
- goto cleanup;
-
- if ((ret = virDomainSaveXML(conn, driver->stateDir, vm->def, xml)))
- goto cleanup;
-
- ret = 0;
-cleanup:
- VIR_FREE(xml);
- return ret;
-}
diff --git a/src/qemu_conf.h b/src/qemu_conf.h
--- a/src/qemu_conf.h
+++ b/src/qemu_conf.h
@@ -92,15 +92,6 @@ struct qemud_driver {
virSecurityDriverPtr securityDriver;
};
-/* Status needed to reconenct to running VMs */
-typedef struct _qemudDomainStatus qemudDomainStatus;
-typedef qemudDomainStatus *qemudDomainStatusPtr;
-struct _qemudDomainStatus {
- char *monitorpath;
- pid_t pid;
- int state;
- virDomainDefPtr def;
-};
/* Port numbers used for KVM migration. */
#define QEMUD_MIGRATION_FIRST_PORT 49152
@@ -141,13 +132,4 @@ virDomainDefPtr qemuParseCommandLine(vir
virDomainDefPtr qemuParseCommandLineString(virConnectPtr conn,
const char *args);
-const char *qemudVirtTypeToString (int type);
-qemudDomainStatusPtr qemudDomainStatusParseFile(virConnectPtr conn,
- virCapsPtr caps,
- const char *filename,
- int flags);
-int qemudSaveDomainStatus(virConnectPtr conn,
- struct qemud_driver *driver,
- virDomainObjPtr vm);
-
#endif /* __QEMUD_CONF_H */
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -125,6 +125,8 @@ static int qemudMonitorCommandExtra(cons
static int qemudDomainSetMemoryBalloon(virConnectPtr conn,
virDomainObjPtr vm,
unsigned long newmem);
+static int qemudDetectVcpuPIDs(virConnectPtr conn,
+ virDomainObjPtr vm);
static struct qemud_driver *qemu_driver = NULL;
@@ -287,79 +289,65 @@ static int qemudOpenMonitor(virConnectPt
const char *monitor,
int reconnect);
+
+/*
+ * Open an existing VM's monitor, and re-detect VCPUs
+ * threads
+ */
+static int
+qemuReconnectDomain(struct qemud_driver *driver,
+ virDomainObjPtr obj)
+{
+ int rc;
+
+ if ((rc = qemudOpenMonitor(NULL, driver, obj, obj->monitorpath, 1)) != 0) {
+ VIR_ERROR(_("Failed to reconnect monitor for %s: %d\n"),
+ obj->def->name, rc);
+ goto error;
+ }
+
+ if (qemudDetectVcpuPIDs(NULL, obj) < 0) {
+ goto error;
+ }
+
+ if (obj->def->seclabel.type == VIR_DOMAIN_SECLABEL_DYNAMIC &&
+ driver->securityDriver &&
+ driver->securityDriver->domainReserveSecurityLabel &&
+ driver->securityDriver->domainReserveSecurityLabel(NULL, obj) < 0)
+ return -1;
+
+ if (obj->def->id >= driver->nextvmid)
+ driver->nextvmid = obj->def->id + 1;
+
+ return 0;
+
+error:
+ return -1;
+}
+
/**
* qemudReconnectVMs
*
- * Reconnect running vms to the daemon process
- */
-static int
-qemudReconnectVMs(struct qemud_driver *driver)
+ * Try to re-open the resources for live VMs that we care
+ * about.
+ */
+static void
+qemuReconnectDomains(struct qemud_driver *driver)
{
int i;
for (i = 0 ; i < driver->domains.count ; i++) {
- virDomainObjPtr vm = driver->domains.objs[i];
- qemudDomainStatusPtr status = NULL;
- char *config = NULL;
- int rc;
-
- virDomainObjLock(vm);
- if ((rc = virFileReadPid(driver->stateDir, vm->def->name, &vm->pid)) == 0)
- DEBUG("Found pid %d for '%s'", vm->pid, vm->def->name);
- else
- goto next;
-
- if ((config = virDomainConfigFile(NULL,
- driver->stateDir,
- vm->def->name)) == NULL) {
- VIR_ERROR(_("Failed to read domain status for %s\n"),
- vm->def->name);
- goto next_error;
- }
-
- status = qemudDomainStatusParseFile(NULL, driver->caps, config, 0);
- if (status) {
- vm->newDef = vm->def;
- vm->def = status->def;
- } else {
- VIR_ERROR(_("Failed to parse domain status for %s\n"),
- vm->def->name);
- goto next_error;
- }
-
- if ((rc = qemudOpenMonitor(NULL, driver, vm, status->monitorpath, 1)) != 0) {
- VIR_ERROR(_("Failed to reconnect monitor for %s: %d\n"),
- vm->def->name, rc);
- goto next_error;
- }
-
- if ((vm->logfile = qemudLogFD(NULL, driver->logDir, vm->def->name)) < 0)
- goto next_error;
-
- if (vm->def->id >= driver->nextvmid)
- driver->nextvmid = vm->def->id + 1;
-
- vm->state = status->state;
- goto next;
-
-next_error:
- /* we failed to reconnect the vm so remove it's traces */
- vm->def->id = -1;
- qemudRemoveDomainStatus(NULL, driver, vm);
- /* Restore orignal def, if we'd loaded a live one */
- if (vm->newDef) {
- virDomainDefFree(vm->def);
- vm->def = vm->newDef;
- vm->newDef = NULL;
- }
-next:
- virDomainObjUnlock(vm);
- if (status)
- VIR_FREE(status->monitorpath);
- VIR_FREE(status);
- VIR_FREE(config);
- }
- return 0;
+ virDomainObjPtr obj = driver->domains.objs[i];
+
+ virDomainObjLock(obj);
+ if (qemuReconnectDomain(driver, obj) < 0) {
+ /* If we can't get the monitor back, then kill the VM
+ * so user has ability to start it again later without
+ * danger of ending up running twice */
+ qemudShutdownVMDaemon(NULL, driver, obj);
+ }
+ virDomainObjUnlock(obj);
+ }
}
static int
@@ -513,14 +501,25 @@ qemudStartup(void) {
goto error;
}
+ /* Get all the running persistent or transient configs first */
+ if (virDomainLoadAllConfigs(NULL,
+ qemu_driver->caps,
+ &qemu_driver->domains,
+ qemu_driver->stateDir,
+ NULL,
+ 1, NULL, NULL) < 0)
+ goto error;
+
+ qemuReconnectDomains(qemu_driver);
+
+ /* Then inactive persistent configs */
if (virDomainLoadAllConfigs(NULL,
qemu_driver->caps,
&qemu_driver->domains,
qemu_driver->configDir,
qemu_driver->autostartDir,
- NULL, NULL) < 0)
- goto error;
- qemudReconnectVMs(qemu_driver);
+ 0, NULL, NULL) < 0)
+ goto error;
qemuDriverUnlock(qemu_driver);
qemudAutostartConfigs(qemu_driver);
@@ -569,7 +568,7 @@ qemudReload(void) {
&qemu_driver->domains,
qemu_driver->configDir,
qemu_driver->autostartDir,
- qemudNotifyLoadDomain, qemu_driver);
+ 0, qemudNotifyLoadDomain, qemu_driver);
qemuDriverUnlock(qemu_driver);
qemudAutostartConfigs(qemu_driver);
@@ -1331,6 +1330,7 @@ static int qemudStartVMDaemon(virConnect
int pos = -1;
char ebuf[1024];
char *pidfile = NULL;
+ int logfile;
struct gemudHookData hookData;
hookData.conn = conn;
@@ -1372,7 +1372,7 @@ static int qemudStartVMDaemon(virConnect
goto cleanup;
}
- if((vm->logfile = qemudLogFD(conn, driver->logDir, vm->def->name)) < 0)
+ if ((logfile = qemudLogFD(conn, driver->logDir, vm->def->name)) < 0)
goto cleanup;
emulator = vm->def->emulator;
@@ -1421,29 +1421,29 @@ static int qemudStartVMDaemon(virConnect
tmp = progenv;
while (*tmp) {
- if (safewrite(vm->logfile, *tmp, strlen(*tmp)) < 0)
+ if (safewrite(logfile, *tmp, strlen(*tmp)) < 0)
VIR_WARN(_("Unable to write envv to logfile: %s\n"),
virStrerror(errno, ebuf, sizeof ebuf));
- if (safewrite(vm->logfile, " ", 1) < 0)
+ if (safewrite(logfile, " ", 1) < 0)
VIR_WARN(_("Unable to write envv to logfile: %s\n"),
virStrerror(errno, ebuf, sizeof ebuf));
tmp++;
}
tmp = argv;
while (*tmp) {
- if (safewrite(vm->logfile, *tmp, strlen(*tmp)) < 0)
+ if (safewrite(logfile, *tmp, strlen(*tmp)) < 0)
VIR_WARN(_("Unable to write argv to logfile: %s\n"),
virStrerror(errno, ebuf, sizeof ebuf));
- if (safewrite(vm->logfile, " ", 1) < 0)
+ if (safewrite(logfile, " ", 1) < 0)
VIR_WARN(_("Unable to write argv to logfile: %s\n"),
virStrerror(errno, ebuf, sizeof ebuf));
tmp++;
}
- if (safewrite(vm->logfile, "\n", 1) < 0)
+ if (safewrite(logfile, "\n", 1) < 0)
VIR_WARN(_("Unable to write argv to logfile: %s\n"),
virStrerror(errno, ebuf, sizeof ebuf));
- if ((pos = lseek(vm->logfile, 0, SEEK_END)) < 0)
+ if ((pos = lseek(logfile, 0, SEEK_END)) < 0)
VIR_WARN(_("Unable to seek to end of logfile: %s\n"),
virStrerror(errno, ebuf, sizeof ebuf));
@@ -1451,7 +1451,7 @@ static int qemudStartVMDaemon(virConnect
FD_SET(tapfds[i], &keepfd);
ret = virExecDaemonize(conn, argv, progenv, &keepfd, &child,
- stdin_fd, &vm->logfile, &vm->logfile,
+ stdin_fd, &logfile, &logfile,
VIR_EXEC_NONBLOCK,
qemudSecurityHook, &hookData,
pidfile);
@@ -1501,7 +1501,7 @@ static int qemudStartVMDaemon(virConnect
(qemudInitCpus(conn, vm, migrateFrom) < 0) ||
(qemudInitPasswords(conn, driver, vm) < 0) ||
(qemudDomainSetMemoryBalloon(conn, vm, vm->def->memory) < 0) ||
- (qemudSaveDomainStatus(conn, qemu_driver, vm) < 0)) {
+ (virDomainSaveStatus(conn, driver->stateDir, vm) < 0)) {
qemudShutdownVMDaemon(conn, driver, vm);
ret = -1;
/* No need for 'goto cleanup' now since qemudShutdownVMDaemon does enough */
@@ -1519,10 +1519,8 @@ cleanup:
vm->def->graphics[0]->type == VIR_DOMAIN_GRAPHICS_TYPE_VNC &&
vm->def->graphics[0]->data.vnc.autoport)
vm->def->graphics[0]->data.vnc.port = -1;
- if (vm->logfile != -1) {
- close(vm->logfile);
- vm->logfile = -1;
- }
+ if (logfile != -1)
+ close(logfile);
vm->def->id = -1;
return -1;
}
@@ -1549,14 +1547,8 @@ static void qemudShutdownVMDaemon(virCon
vm->monitorWatch = -1;
}
- if (close(vm->logfile) < 0) {
- char ebuf[1024];
- VIR_WARN(_("Unable to close logfile: %s\n"),
- virStrerror(errno, ebuf, sizeof ebuf));
- }
if (vm->monitor != -1)
close(vm->monitor);
- vm->logfile = -1;
vm->monitor = -1;
/* shut it off for sure */
@@ -2260,7 +2252,7 @@ static int qemudDomainSuspend(virDomainP
VIR_DOMAIN_EVENT_SUSPENDED_PAUSED);
VIR_FREE(info);
}
- if (qemudSaveDomainStatus(dom->conn, driver, vm) < 0)
+ if (virDomainSaveStatus(dom->conn, driver->stateDir, vm) < 0)
goto cleanup;
ret = 0;
@@ -2310,7 +2302,7 @@ static int qemudDomainResume(virDomainPt
VIR_DOMAIN_EVENT_RESUMED_UNPAUSED);
VIR_FREE(info);
}
- if (qemudSaveDomainStatus(dom->conn, driver, vm) < 0)
+ if (virDomainSaveStatus(dom->conn, driver->stateDir, vm) < 0)
goto cleanup;
ret = 0;
@@ -4192,7 +4184,7 @@ static int qemudDomainAttachDevice(virDo
goto cleanup;
}
- if (!ret && qemudSaveDomainStatus(dom->conn, driver, vm) < 0)
+ if (!ret && virDomainSaveStatus(dom->conn, driver->stateDir, vm) < 0)
ret = -1;
cleanup:
@@ -4314,7 +4306,7 @@ static int qemudDomainDetachDevice(virDo
qemudReportError(dom->conn, dom, NULL, VIR_ERR_NO_SUPPORT,
"%s", _("only SCSI or virtio disk device can be detached dynamically"));
- if (!ret && qemudSaveDomainStatus(dom->conn, driver, vm) < 0)
+ if (!ret && virDomainSaveStatus(dom->conn, driver->stateDir, vm) < 0)
ret = -1;
cleanup:
diff --git a/src/security.h b/src/security.h
--- a/src/security.h
+++ b/src/security.h
@@ -38,6 +38,8 @@ typedef int (*virSecurityDomainSetImageL
virDomainDiskDefPtr disk);
typedef int (*virSecurityDomainGenLabel) (virConnectPtr conn,
virDomainObjPtr sec);
+typedef int (*virSecurityDomainReserveLabel) (virConnectPtr conn,
+ virDomainObjPtr sec);
typedef int (*virSecurityDomainGetLabel) (virConnectPtr conn,
virDomainObjPtr vm,
virSecurityLabelPtr sec);
@@ -57,6 +59,7 @@ struct _virSecurityDriver {
virSecurityDomainRestoreImageLabel domainRestoreSecurityImageLabel;
virSecurityDomainSetImageLabel domainSetSecurityImageLabel;
virSecurityDomainGenLabel domainGenSecurityLabel;
+ virSecurityDomainReserveLabel domainReserveSecurityLabel;
virSecurityDomainGetLabel domainGetSecurityLabel;
virSecurityDomainSetLabel domainSetSecurityLabel;
virSecurityDomainRestoreLabel domainRestoreSecurityLabel;
diff --git a/src/security_selinux.c b/src/security_selinux.c
--- a/src/security_selinux.c
+++ b/src/security_selinux.c
@@ -216,6 +216,44 @@ done:
}
static int
+SELinuxReserveSecurityLabel(virConnectPtr conn,
+ virDomainObjPtr vm)
+{
+ security_context_t pctx;
+ context_t ctx = NULL;
+ const char *mcs;
+
+ if (getpidcon(vm->pid, &pctx) == -1) {
+ char ebuf[1024];
+ virSecurityReportError(conn, VIR_ERR_ERROR, _("%s: error calling "
+ "getpidcon(): %s"), __func__,
+ virStrerror(errno, ebuf, sizeof ebuf));
+ return -1;
+ }
+
+ ctx = context_new(pctx);
+ VIR_FREE(pctx);
+ if (!ctx)
+ goto err;
+
+ mcs = context_range_get(ctx);
+ if (!mcs)
+ goto err;
+
+ mcsAdd(mcs);
+
+ context_free(ctx);
+
+ return 0;
+
+err:
+ context_free(ctx);
+ return -1;
+}
+
+
+
+static int
SELinuxSecurityDriverProbe(void)
{
return is_selinux_enabled() ? SECURITY_DRIVER_ENABLE : SECURITY_DRIVER_DISABLE;
@@ -422,6 +460,7 @@ virSecurityDriver virSELinuxSecurityDriv
.domainSetSecurityImageLabel = SELinuxSetSecurityImageLabel,
.domainRestoreSecurityImageLabel = SELinuxRestoreSecurityImageLabel,
.domainGenSecurityLabel = SELinuxGenSecurityLabel,
+ .domainReserveSecurityLabel = SELinuxReserveSecurityLabel,
.domainGetSecurityLabel = SELinuxGetSecurityLabel,
.domainRestoreSecurityLabel = SELinuxRestoreSecurityLabel,
.domainSetSecurityLabel = SELinuxSetSecurityLabel,
diff --git a/src/uml_driver.c b/src/uml_driver.c
--- a/src/uml_driver.c
+++ b/src/uml_driver.c
@@ -399,7 +399,7 @@ umlStartup(void) {
¨_driver->domains,
uml_driver->configDir,
uml_driver->autostartDir,
- NULL, NULL) < 0)
+ 0, NULL, NULL) < 0)
goto error;
umlAutostartConfigs(uml_driver);
@@ -438,7 +438,7 @@ umlReload(void) {
¨_driver->domains,
uml_driver->configDir,
uml_driver->autostartDir,
- NULL, NULL);
+ 0, NULL, NULL);
umlAutostartConfigs(uml_driver);
umlDriverUnlock(uml_driver);
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
15 years, 7 months
[libvirt] PATCH: Include OS driver name in device information
by Daniel P. Berrange
This patch extends the node device XML from
$ virsh nodedev-dumpxml pci_8086_27d6
<device>
<name>pci_8086_27d6</name>
<parent>computer</parent>
<capability type='pci'>
<domain>0</domain>
<bus>0</bus>
<slot>28</slot>
<function>3</function>
<product id='0x27d6'>82801G (ICH7 Family) PCI Express Port 4</product>
<vendor id='0x8086'>Intel Corporation</vendor>
</capability>
</device>
To, also include the operating system driver name.
$ virsh nodedev-dumpxml pci_8086_27d6
<device>
<name>pci_8086_27d6</name>
<parent>computer</parent>
<driver>
<name>pcieport-driver</name>
</driver>
<capability type='pci'>
<domain>0</domain>
<bus>0</bus>
<slot>28</slot>
<function>3</function>
<product id='0x27d6'>82801G (ICH7 Family) PCI Express Port 4</product>
<vendor id='0x8086'>Intel Corporation</vendor>
</capability>
</device>
We're not defining any particular semantics for the driver name, it is
just a opaque string following rules of the OS in question.
Daniel
diff -r ec78a5d6c00c src/node_device.c
--- a/src/node_device.c Thu May 28 14:42:24 2009 +0100
+++ b/src/node_device.c Thu May 28 16:00:12 2009 +0100
@@ -46,6 +46,60 @@ static int dev_has_cap(const virNodeDevi
return 0;
}
+#ifdef __linux__
+static int update_driver_name(virConnectPtr conn,
+ virNodeDeviceObjPtr dev)
+{
+ char *driver_link = NULL;
+ char devpath[PATH_MAX];
+ char *p;
+ int ret = -1;
+ int n;
+
+ VIR_FREE(dev->def->driver);
+
+ if (virAsprintf(&driver_link, "%s/driver", dev->devicePath) < 0) {
+ virReportOOMError(conn);
+ goto cleanup;
+ }
+
+ /* Some devices don't have an explicit driver, so just return
+ without a name */
+ if (access(driver_link, R_OK) < 0) {
+ ret = 0;
+ goto cleanup;
+ }
+
+ if ((n = readlink(driver_link, devpath, sizeof devpath)) < 0) {
+ virReportSystemError(conn, errno,
+ _("cannot resolve driver link %s"), driver_link);
+ goto cleanup;
+ }
+ devpath[n] = '\0';
+
+ p = strrchr(devpath, '/');
+ if (p) {
+ dev->def->driver = strdup(p+1);
+ if (!dev->def->driver) {
+ virReportOOMError(conn);
+ goto cleanup;
+ }
+ }
+ ret = 0;
+
+cleanup:
+ VIR_FREE(driver_link);
+ return ret;
+}
+#else
+/* XXX: Implement me for non-linux */
+static int update_driver_name(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virNodeDeviceObjPtr dev ATTRIBUTE_UNUSED)
+{
+ return 0;
+}
+#endif
+
void nodeDeviceLock(virDeviceMonitorStatePtr driver)
{
@@ -150,6 +204,7 @@ static char *nodeDeviceDumpXML(virNodeDe
goto cleanup;
}
+ update_driver_name(dev->conn, obj);
ret = virNodeDeviceDefFormat(dev->conn, obj->def);
cleanup:
diff -r ec78a5d6c00c src/node_device_conf.c
--- a/src/node_device_conf.c Thu May 28 14:42:24 2009 +0100
+++ b/src/node_device_conf.c Thu May 28 16:00:12 2009 +0100
@@ -78,6 +78,7 @@ void virNodeDeviceDefFree(virNodeDeviceD
VIR_FREE(def->name);
VIR_FREE(def->parent);
+ VIR_FREE(def->driver);
caps = def->caps;
while (caps) {
@@ -94,6 +95,7 @@ void virNodeDeviceObjFree(virNodeDeviceO
if (!dev)
return;
+ VIR_FREE(dev->devicePath);
virNodeDeviceDefFree(dev->def);
if (dev->privateFree)
(*dev->privateFree)(dev->privateData);
@@ -191,6 +193,11 @@ char *virNodeDeviceDefFormat(virConnectP
if (def->parent)
virBufferEscapeString(&buf, " <parent>%s</parent>\n", def->parent);
+ if (def->driver) {
+ virBufferAddLit(&buf, " <driver>\n");
+ virBufferEscapeString(&buf, " <name>%s</name>\n", def->driver);
+ virBufferAddLit(&buf, " </driver>\n");
+ }
for (caps = def->caps; caps; caps = caps->next) {
char uuidstr[VIR_UUID_STRING_BUFLEN];
diff -r ec78a5d6c00c src/node_device_conf.h
--- a/src/node_device_conf.h Thu May 28 14:42:24 2009 +0100
+++ b/src/node_device_conf.h Thu May 28 16:00:12 2009 +0100
@@ -136,6 +136,7 @@ typedef virNodeDeviceDef *virNodeDeviceD
struct _virNodeDeviceDef {
char *name; /* device name (unique on node) */
char *parent; /* optional parent device name */
+ char *driver; /* optional driver name */
virNodeDevCapsDefPtr caps; /* optional device capabilities */
};
@@ -145,6 +146,7 @@ typedef virNodeDeviceObj *virNodeDeviceO
struct _virNodeDeviceObj {
virMutex lock;
+ char *devicePath; /* OS specific path to device metadat, eg sysfs */
virNodeDeviceDefPtr def; /* device definition */
void *privateData; /* driver-specific private data */
void (*privateFree)(void *data); /* destructor for private data */
diff -r ec78a5d6c00c src/node_device_hal.c
--- a/src/node_device_hal.c Thu May 28 14:42:24 2009 +0100
+++ b/src/node_device_hal.c Thu May 28 16:00:12 2009 +0100
@@ -413,6 +413,7 @@ static void dev_create(const char *udi)
const char *name = hal_name(udi);
int rv;
char *privData = strdup(udi);
+ char *devicePath = NULL;
if (!privData)
return;
@@ -439,15 +440,22 @@ static void dev_create(const char *udi)
if (def->caps == NULL)
goto cleanup;
+ /* Some devices don't have a path in sysfs, so ignore failure */
+ get_str_prop(ctx, udi, "linux.sysfs_path", &devicePath);
+
dev = virNodeDeviceAssignDef(NULL,
&driverState->devs,
def);
- if (!dev)
+ if (!dev) {
+ VIR_FREE(devicePath);
goto failure;
+ }
dev->privateData = privData;
dev->privateFree = free_udi;
+ dev->devicePath = devicePath;
+
virNodeDeviceObjUnlock(dev);
nodeDeviceUnlock(driverState);
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
15 years, 7 months
[libvirt] PATCH Fix BuildRequires in spec file
by Trent Johnson
Fixes error from rpmbuild
RPM build errors:
File not found:
/var/tmp/libvirt-0.6.3-1.el5-root/usr/libexec/libvirt_parthelper
diff -u -r libvirt.spec.orig libvirt.spec
--- libvirt.spec.orig 2009-04-24 08:58:29.000000000 -0500
+++ libvirt.spec 2009-05-29 09:57:56.000000000 -0500
@@ -59,7 +59,7 @@
Source: libvirt-%{version}.tar.gz
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root
URL: http://libvirt.org/
-BuildRequires: python python-devel
+BuildRequires: python python-devel e2fsprogs-devel
Requires: libxml2
Requires: readline
Requires: ncurses
15 years, 7 months
[libvirt] PATCH: Fix mingw32 build
by Daniel P. Berrange
On Win32/mingw32 the name 'interface' is #defined to the COM_interface
struct. Needless to say, libvirt thus fails to build in spectacular ways.
This patch does s/interface/iface/ on all variables. It also fixes
bugs in the qemud/Makefile.am and tests/testutils.h files
include/libvirt/libvirt.h | 18 +++---
include/libvirt/libvirt.h.in | 18 +++---
qemud/Makefile.am | 6 +-
qemud/remote.c | 82 ++++++++++++++---------------
qemud/remote_protocol.c | 14 ++---
qemud/remote_protocol.h | 14 ++---
qemud/remote_protocol.x | 14 ++---
src/datatypes.c | 36 ++++++------
src/datatypes.h | 2
src/driver.h | 8 +-
src/libvirt.c | 120 +++++++++++++++++++++----------------------
src/remote_internal.c | 56 ++++++++++----------
tests/testutils.c | 10 +++
13 files changed, 206 insertions(+), 192 deletions(-)
Daniel
Index: include/libvirt/libvirt.h
===================================================================
RCS file: /data/cvs/libvirt/include/libvirt/libvirt.h,v
retrieving revision 1.105
diff -u -p -r1.105 libvirt.h
--- include/libvirt/libvirt.h 21 May 2009 13:46:36 -0000 1.105
+++ include/libvirt/libvirt.h 28 May 2009 16:32:53 -0000
@@ -883,7 +883,7 @@ typedef struct _virInterface virInterfac
*/
typedef virInterface *virInterfacePtr;
-virConnectPtr virInterfaceGetConnect (virInterfacePtr interface);
+virConnectPtr virInterfaceGetConnect (virInterfacePtr iface);
int virConnectNumOfInterfaces (virConnectPtr conn);
int virConnectListInterfaces (virConnectPtr conn,
@@ -895,25 +895,25 @@ virInterfacePtr virInterfaceLook
virInterfacePtr virInterfaceLookupByMACString (virConnectPtr conn,
const char *mac);
-const char* virInterfaceGetName (virInterfacePtr interface);
-const char* virInterfaceGetMACString (virInterfacePtr interface);
+const char* virInterfaceGetName (virInterfacePtr iface);
+const char* virInterfaceGetMACString (virInterfacePtr iface);
-char * virInterfaceGetXMLDesc (virInterfacePtr interface,
+char * virInterfaceGetXMLDesc (virInterfacePtr iface,
unsigned int flags);
virInterfacePtr virInterfaceDefineXML (virConnectPtr conn,
const char *xmlDesc,
unsigned int flags);
-int virInterfaceUndefine (virInterfacePtr interface);
+int virInterfaceUndefine (virInterfacePtr iface);
-int virInterfaceCreate (virInterfacePtr interface,
+int virInterfaceCreate (virInterfacePtr iface,
unsigned int flags);
-int virInterfaceDestroy (virInterfacePtr interface,
+int virInterfaceDestroy (virInterfacePtr iface,
unsigned int flags);
-int virInterfaceRef (virInterfacePtr interface);
-int virInterfaceFree (virInterfacePtr interface);
+int virInterfaceRef (virInterfacePtr iface);
+int virInterfaceFree (virInterfacePtr iface);
/**
* virStoragePool:
Index: include/libvirt/libvirt.h.in
===================================================================
RCS file: /data/cvs/libvirt/include/libvirt/libvirt.h.in,v
retrieving revision 1.70
diff -u -p -r1.70 libvirt.h.in
--- include/libvirt/libvirt.h.in 21 May 2009 13:46:36 -0000 1.70
+++ include/libvirt/libvirt.h.in 28 May 2009 16:32:53 -0000
@@ -883,7 +883,7 @@ typedef struct _virInterface virInterfac
*/
typedef virInterface *virInterfacePtr;
-virConnectPtr virInterfaceGetConnect (virInterfacePtr interface);
+virConnectPtr virInterfaceGetConnect (virInterfacePtr iface);
int virConnectNumOfInterfaces (virConnectPtr conn);
int virConnectListInterfaces (virConnectPtr conn,
@@ -895,25 +895,25 @@ virInterfacePtr virInterfaceLook
virInterfacePtr virInterfaceLookupByMACString (virConnectPtr conn,
const char *mac);
-const char* virInterfaceGetName (virInterfacePtr interface);
-const char* virInterfaceGetMACString (virInterfacePtr interface);
+const char* virInterfaceGetName (virInterfacePtr iface);
+const char* virInterfaceGetMACString (virInterfacePtr iface);
-char * virInterfaceGetXMLDesc (virInterfacePtr interface,
+char * virInterfaceGetXMLDesc (virInterfacePtr iface,
unsigned int flags);
virInterfacePtr virInterfaceDefineXML (virConnectPtr conn,
const char *xmlDesc,
unsigned int flags);
-int virInterfaceUndefine (virInterfacePtr interface);
+int virInterfaceUndefine (virInterfacePtr iface);
-int virInterfaceCreate (virInterfacePtr interface,
+int virInterfaceCreate (virInterfacePtr iface,
unsigned int flags);
-int virInterfaceDestroy (virInterfacePtr interface,
+int virInterfaceDestroy (virInterfacePtr iface,
unsigned int flags);
-int virInterfaceRef (virInterfacePtr interface);
-int virInterfaceFree (virInterfacePtr interface);
+int virInterfaceRef (virInterfacePtr iface);
+int virInterfaceFree (virInterfacePtr iface);
/**
* virStoragePool:
Index: qemud/Makefile.am
===================================================================
RCS file: /data/cvs/libvirt/qemud/Makefile.am,v
retrieving revision 1.78
diff -u -p -r1.78 Makefile.am
--- qemud/Makefile.am 25 May 2009 11:56:00 -0000 1.78
+++ qemud/Makefile.am 28 May 2009 16:32:53 -0000
@@ -31,7 +31,7 @@ EXTRA_DIST = \
$(AVAHI_SOURCES) \
$(DAEMON_SOURCES)
-BUILT_SOURCES = libvirtd.init libvirtd.logrotate
+BUILT_SOURCES =
if HAVE_RPCGEN
#
@@ -218,6 +218,8 @@ remote_dispatch_args.h: $(srcdir)/remote
remote_dispatch_ret.h: $(srcdir)/remote_generate_stubs.pl remote_protocol.x
perl -w $(srcdir)/remote_generate_stubs.pl -r $(srcdir)/remote_protocol.x > $@
+BUILT_SOURCES += libvirtd.logrotate
+
libvirtd.logrotate: libvirtd.logrotate.in
sed \
-e s!\@localstatedir\@!@localstatedir@!g \
@@ -242,6 +244,8 @@ uninstall-init:
rm -f $(DESTDIR)$(sysconfdir)/rc.d/init.d/libvirtd \
$(DESTDIR)$(sysconfdir)/sysconfig/libvirtd
+BUILT_SOURCES += libvirtd.init
+
libvirtd.init: libvirtd.init.in
sed \
-e s!\@localstatedir\@!@localstatedir@!g \
Index: qemud/remote.c
===================================================================
RCS file: /data/cvs/libvirt/qemud/remote.c,v
retrieving revision 1.71
diff -u -p -r1.71 remote.c
--- qemud/remote.c 21 May 2009 13:50:56 -0000 1.71
+++ qemud/remote.c 28 May 2009 16:32:54 -0000
@@ -2664,16 +2664,16 @@ remoteDispatchInterfaceLookupByName (str
remote_interface_lookup_by_name_args *args,
remote_interface_lookup_by_name_ret *ret)
{
- virInterfacePtr interface;
+ virInterfacePtr iface;
- interface = virInterfaceLookupByName (conn, args->name);
- if (interface == NULL) {
+ iface = virInterfaceLookupByName (conn, args->name);
+ if (iface == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_interface (&ret->interface, interface);
- virInterfaceFree(interface);
+ make_nonnull_interface (&ret->iface, iface);
+ virInterfaceFree(iface);
return 0;
}
@@ -2685,16 +2685,16 @@ remoteDispatchInterfaceLookupByMacString
remote_interface_lookup_by_mac_string_args *args,
remote_interface_lookup_by_mac_string_ret *ret)
{
- virInterfacePtr interface;
+ virInterfacePtr iface;
- interface = virInterfaceLookupByMACString (conn, args->mac);
- if (interface == NULL) {
+ iface = virInterfaceLookupByMACString (conn, args->mac);
+ if (iface == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_interface (&ret->interface, interface);
- virInterfaceFree(interface);
+ make_nonnull_interface (&ret->iface, iface);
+ virInterfaceFree(iface);
return 0;
}
@@ -2706,22 +2706,22 @@ remoteDispatchInterfaceGetXmlDesc (struc
remote_interface_get_xml_desc_args *args,
remote_interface_get_xml_desc_ret *ret)
{
- virInterfacePtr interface;
+ virInterfacePtr iface;
- interface = get_nonnull_interface (conn, args->interface);
- if (interface == NULL) {
+ iface = get_nonnull_interface (conn, args->iface);
+ if (iface == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
/* remoteDispatchClientRequest will free this. */
- ret->xml = virInterfaceGetXMLDesc (interface, args->flags);
+ ret->xml = virInterfaceGetXMLDesc (iface, args->flags);
if (!ret->xml) {
- virInterfaceFree(interface);
+ virInterfaceFree(iface);
remoteDispatchConnError(rerr, conn);
return -1;
}
- virInterfaceFree(interface);
+ virInterfaceFree(iface);
return 0;
}
@@ -2733,16 +2733,16 @@ remoteDispatchInterfaceDefineXml (struct
remote_interface_define_xml_args *args,
remote_interface_define_xml_ret *ret)
{
- virInterfacePtr interface;
+ virInterfacePtr iface;
- interface = virInterfaceDefineXML (conn, args->xml, args->flags);
- if (interface == NULL) {
+ iface = virInterfaceDefineXML (conn, args->xml, args->flags);
+ if (iface == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- make_nonnull_interface (&ret->interface, interface);
- virInterfaceFree(interface);
+ make_nonnull_interface (&ret->iface, iface);
+ virInterfaceFree(iface);
return 0;
}
@@ -2754,20 +2754,20 @@ remoteDispatchInterfaceUndefine (struct
remote_interface_undefine_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virInterfacePtr interface;
+ virInterfacePtr iface;
- interface = get_nonnull_interface (conn, args->interface);
- if (interface == NULL) {
+ iface = get_nonnull_interface (conn, args->iface);
+ if (iface == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virInterfaceUndefine (interface) == -1) {
- virInterfaceFree(interface);
+ if (virInterfaceUndefine (iface) == -1) {
+ virInterfaceFree(iface);
remoteDispatchConnError(rerr, conn);
return -1;
}
- virInterfaceFree(interface);
+ virInterfaceFree(iface);
return 0;
}
@@ -2779,20 +2779,20 @@ remoteDispatchInterfaceCreate (struct qe
remote_interface_create_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virInterfacePtr interface;
+ virInterfacePtr iface;
- interface = get_nonnull_interface (conn, args->interface);
- if (interface == NULL) {
+ iface = get_nonnull_interface (conn, args->iface);
+ if (iface == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virInterfaceCreate (interface, args->flags) == -1) {
- virInterfaceFree(interface);
+ if (virInterfaceCreate (iface, args->flags) == -1) {
+ virInterfaceFree(iface);
remoteDispatchConnError(rerr, conn);
return -1;
}
- virInterfaceFree(interface);
+ virInterfaceFree(iface);
return 0;
}
@@ -2804,20 +2804,20 @@ remoteDispatchInterfaceDestroy (struct q
remote_interface_destroy_args *args,
void *ret ATTRIBUTE_UNUSED)
{
- virInterfacePtr interface;
+ virInterfacePtr iface;
- interface = get_nonnull_interface (conn, args->interface);
- if (interface == NULL) {
+ iface = get_nonnull_interface (conn, args->iface);
+ if (iface == NULL) {
remoteDispatchConnError(rerr, conn);
return -1;
}
- if (virInterfaceDestroy (interface, args->flags) == -1) {
- virInterfaceFree(interface);
+ if (virInterfaceDestroy (iface, args->flags) == -1) {
+ virInterfaceFree(iface);
remoteDispatchConnError(rerr, conn);
return -1;
}
- virInterfaceFree(interface);
+ virInterfaceFree(iface);
return 0;
}
@@ -4823,9 +4823,9 @@ get_nonnull_network (virConnectPtr conn,
}
static virInterfacePtr
-get_nonnull_interface (virConnectPtr conn, remote_nonnull_interface interface)
+get_nonnull_interface (virConnectPtr conn, remote_nonnull_interface iface)
{
- return virGetInterface (conn, interface.name, interface.mac);
+ return virGetInterface (conn, iface.name, iface.mac);
}
static virStoragePoolPtr
Index: qemud/remote_protocol.c
===================================================================
RCS file: /data/cvs/libvirt/qemud/remote_protocol.c,v
retrieving revision 1.34
diff -u -p -r1.34 remote_protocol.c
--- qemud/remote_protocol.c 21 May 2009 13:50:56 -0000 1.34
+++ qemud/remote_protocol.c 28 May 2009 16:32:54 -0000
@@ -1530,7 +1530,7 @@ bool_t
xdr_remote_interface_lookup_by_name_ret (XDR *xdrs, remote_interface_lookup_by_name_ret *objp)
{
- if (!xdr_remote_nonnull_interface (xdrs, &objp->interface))
+ if (!xdr_remote_nonnull_interface (xdrs, &objp->iface))
return FALSE;
return TRUE;
}
@@ -1548,7 +1548,7 @@ bool_t
xdr_remote_interface_lookup_by_mac_string_ret (XDR *xdrs, remote_interface_lookup_by_mac_string_ret *objp)
{
- if (!xdr_remote_nonnull_interface (xdrs, &objp->interface))
+ if (!xdr_remote_nonnull_interface (xdrs, &objp->iface))
return FALSE;
return TRUE;
}
@@ -1557,7 +1557,7 @@ bool_t
xdr_remote_interface_get_xml_desc_args (XDR *xdrs, remote_interface_get_xml_desc_args *objp)
{
- if (!xdr_remote_nonnull_interface (xdrs, &objp->interface))
+ if (!xdr_remote_nonnull_interface (xdrs, &objp->iface))
return FALSE;
if (!xdr_u_int (xdrs, &objp->flags))
return FALSE;
@@ -1588,7 +1588,7 @@ bool_t
xdr_remote_interface_define_xml_ret (XDR *xdrs, remote_interface_define_xml_ret *objp)
{
- if (!xdr_remote_nonnull_interface (xdrs, &objp->interface))
+ if (!xdr_remote_nonnull_interface (xdrs, &objp->iface))
return FALSE;
return TRUE;
}
@@ -1597,7 +1597,7 @@ bool_t
xdr_remote_interface_undefine_args (XDR *xdrs, remote_interface_undefine_args *objp)
{
- if (!xdr_remote_nonnull_interface (xdrs, &objp->interface))
+ if (!xdr_remote_nonnull_interface (xdrs, &objp->iface))
return FALSE;
return TRUE;
}
@@ -1606,7 +1606,7 @@ bool_t
xdr_remote_interface_create_args (XDR *xdrs, remote_interface_create_args *objp)
{
- if (!xdr_remote_nonnull_interface (xdrs, &objp->interface))
+ if (!xdr_remote_nonnull_interface (xdrs, &objp->iface))
return FALSE;
if (!xdr_u_int (xdrs, &objp->flags))
return FALSE;
@@ -1617,7 +1617,7 @@ bool_t
xdr_remote_interface_destroy_args (XDR *xdrs, remote_interface_destroy_args *objp)
{
- if (!xdr_remote_nonnull_interface (xdrs, &objp->interface))
+ if (!xdr_remote_nonnull_interface (xdrs, &objp->iface))
return FALSE;
if (!xdr_u_int (xdrs, &objp->flags))
return FALSE;
Index: qemud/remote_protocol.h
===================================================================
RCS file: /data/cvs/libvirt/qemud/remote_protocol.h,v
retrieving revision 1.33
diff -u -p -r1.33 remote_protocol.h
--- qemud/remote_protocol.h 21 May 2009 13:50:56 -0000 1.33
+++ qemud/remote_protocol.h 28 May 2009 16:32:54 -0000
@@ -853,7 +853,7 @@ struct remote_interface_lookup_by_name_a
typedef struct remote_interface_lookup_by_name_args remote_interface_lookup_by_name_args;
struct remote_interface_lookup_by_name_ret {
- remote_nonnull_interface interface;
+ remote_nonnull_interface iface;
};
typedef struct remote_interface_lookup_by_name_ret remote_interface_lookup_by_name_ret;
@@ -863,12 +863,12 @@ struct remote_interface_lookup_by_mac_st
typedef struct remote_interface_lookup_by_mac_string_args remote_interface_lookup_by_mac_string_args;
struct remote_interface_lookup_by_mac_string_ret {
- remote_nonnull_interface interface;
+ remote_nonnull_interface iface;
};
typedef struct remote_interface_lookup_by_mac_string_ret remote_interface_lookup_by_mac_string_ret;
struct remote_interface_get_xml_desc_args {
- remote_nonnull_interface interface;
+ remote_nonnull_interface iface;
u_int flags;
};
typedef struct remote_interface_get_xml_desc_args remote_interface_get_xml_desc_args;
@@ -885,23 +885,23 @@ struct remote_interface_define_xml_args
typedef struct remote_interface_define_xml_args remote_interface_define_xml_args;
struct remote_interface_define_xml_ret {
- remote_nonnull_interface interface;
+ remote_nonnull_interface iface;
};
typedef struct remote_interface_define_xml_ret remote_interface_define_xml_ret;
struct remote_interface_undefine_args {
- remote_nonnull_interface interface;
+ remote_nonnull_interface iface;
};
typedef struct remote_interface_undefine_args remote_interface_undefine_args;
struct remote_interface_create_args {
- remote_nonnull_interface interface;
+ remote_nonnull_interface iface;
u_int flags;
};
typedef struct remote_interface_create_args remote_interface_create_args;
struct remote_interface_destroy_args {
- remote_nonnull_interface interface;
+ remote_nonnull_interface iface;
u_int flags;
};
typedef struct remote_interface_destroy_args remote_interface_destroy_args;
Index: qemud/remote_protocol.x
===================================================================
RCS file: /data/cvs/libvirt/qemud/remote_protocol.x,v
retrieving revision 1.32
diff -u -p -r1.32 remote_protocol.x
--- qemud/remote_protocol.x 21 May 2009 13:50:56 -0000 1.32
+++ qemud/remote_protocol.x 28 May 2009 16:32:54 -0000
@@ -798,7 +798,7 @@ struct remote_interface_lookup_by_name_a
};
struct remote_interface_lookup_by_name_ret {
- remote_nonnull_interface interface;
+ remote_nonnull_interface iface;
};
struct remote_interface_lookup_by_mac_string_args {
@@ -806,11 +806,11 @@ struct remote_interface_lookup_by_mac_st
};
struct remote_interface_lookup_by_mac_string_ret {
- remote_nonnull_interface interface;
+ remote_nonnull_interface iface;
};
struct remote_interface_get_xml_desc_args {
- remote_nonnull_interface interface;
+ remote_nonnull_interface iface;
unsigned int flags;
};
@@ -824,20 +824,20 @@ struct remote_interface_define_xml_args
};
struct remote_interface_define_xml_ret {
- remote_nonnull_interface interface;
+ remote_nonnull_interface iface;
};
struct remote_interface_undefine_args {
- remote_nonnull_interface interface;
+ remote_nonnull_interface iface;
};
struct remote_interface_create_args {
- remote_nonnull_interface interface;
+ remote_nonnull_interface iface;
unsigned int flags;
};
struct remote_interface_destroy_args {
- remote_nonnull_interface interface;
+ remote_nonnull_interface iface;
unsigned int flags;
};
Index: src/datatypes.c
===================================================================
RCS file: /data/cvs/libvirt/src/datatypes.c,v
retrieving revision 1.12
diff -u -p -r1.12 datatypes.c
--- src/datatypes.c 20 May 2009 14:26:50 -0000 1.12
+++ src/datatypes.c 28 May 2009 16:32:54 -0000
@@ -75,9 +75,9 @@ virNetworkFreeName(virNetworkPtr network
* Returns 0 in case of success and -1 in case of failure.
*/
static int
-virInterfaceFreeName(virInterfacePtr interface, const char *name ATTRIBUTE_UNUSED)
+virInterfaceFreeName(virInterfacePtr iface, const char *name ATTRIBUTE_UNUSED)
{
- return (virUnrefInterface(interface));
+ return (virUnrefInterface(iface));
}
/**
@@ -589,19 +589,19 @@ virGetInterface(virConnectPtr conn, cons
* which may also be released if its ref count hits zero.
*/
static void
-virReleaseInterface(virInterfacePtr interface) {
- virConnectPtr conn = interface->conn;
- DEBUG("release interface %p %s", interface, interface->name);
+virReleaseInterface(virInterfacePtr iface) {
+ virConnectPtr conn = iface->conn;
+ DEBUG("release interface %p %s", iface, iface->name);
/* TODO search by MAC first as they are better differenciators */
- if (virHashRemoveEntry(conn->interfaces, interface->name, NULL) < 0)
+ if (virHashRemoveEntry(conn->interfaces, iface->name, NULL) < 0)
virLibConnError(conn, VIR_ERR_INTERNAL_ERROR,
_("interface missing from connection hash table"));
- interface->magic = -1;
- VIR_FREE(interface->name);
- VIR_FREE(interface->mac);
- VIR_FREE(interface);
+ iface->magic = -1;
+ VIR_FREE(iface->name);
+ VIR_FREE(iface->mac);
+ VIR_FREE(iface);
DEBUG("unref connection %p %d", conn, conn->refs);
conn->refs--;
@@ -625,24 +625,24 @@ virReleaseInterface(virInterfacePtr inte
* Returns the reference count or -1 in case of failure.
*/
int
-virUnrefInterface(virInterfacePtr interface) {
+virUnrefInterface(virInterfacePtr iface) {
int refs;
- if (!VIR_IS_CONNECTED_INTERFACE(interface)) {
+ if (!VIR_IS_CONNECTED_INTERFACE(iface)) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
return(-1);
}
- virMutexLock(&interface->conn->lock);
- DEBUG("unref interface %p %s %d", interface, interface->name, interface->refs);
- interface->refs--;
- refs = interface->refs;
+ virMutexLock(&iface->conn->lock);
+ DEBUG("unref interface %p %s %d", iface, iface->name, iface->refs);
+ iface->refs--;
+ refs = iface->refs;
if (refs == 0) {
- virReleaseInterface(interface);
+ virReleaseInterface(iface);
/* Already unlocked mutex */
return (0);
}
- virMutexUnlock(&interface->conn->lock);
+ virMutexUnlock(&iface->conn->lock);
return (refs);
}
Index: src/datatypes.h
===================================================================
RCS file: /data/cvs/libvirt/src/datatypes.h,v
retrieving revision 1.8
diff -u -p -r1.8 datatypes.h
--- src/datatypes.h 20 May 2009 14:26:50 -0000 1.8
+++ src/datatypes.h 28 May 2009 16:32:54 -0000
@@ -254,7 +254,7 @@ int virUnrefNetwork(virNetworkPtr networ
virInterfacePtr virGetInterface(virConnectPtr conn,
const char *name,
const char *mac);
-int virUnrefInterface(virInterfacePtr interface);
+int virUnrefInterface(virInterfacePtr iface);
virStoragePoolPtr virGetStoragePool(virConnectPtr conn,
const char *name,
Index: src/driver.h
===================================================================
RCS file: /data/cvs/libvirt/src/driver.h,v
retrieving revision 1.75
diff -u -p -r1.75 driver.h
--- src/driver.h 25 May 2009 11:56:00 -0000 1.75
+++ src/driver.h 28 May 2009 16:32:54 -0000
@@ -516,7 +516,7 @@ typedef virInterfacePtr
const char *mac);
typedef char *
- (*virDrvInterfaceGetXMLDesc) (virInterfacePtr interface,
+ (*virDrvInterfaceGetXMLDesc) (virInterfacePtr iface,
unsigned int flags);
typedef virInterfacePtr
@@ -524,12 +524,12 @@ typedef virInterfacePtr
const char *xmlDesc,
unsigned int flags);
typedef int
- (*virDrvInterfaceUndefine) (virInterfacePtr interface);
+ (*virDrvInterfaceUndefine) (virInterfacePtr iface);
typedef int
- (*virDrvInterfaceCreate) (virInterfacePtr interface,
+ (*virDrvInterfaceCreate) (virInterfacePtr iface,
unsigned int flags);
typedef int
- (*virDrvInterfaceDestroy) (virInterfacePtr interface,
+ (*virDrvInterfaceDestroy) (virInterfacePtr iface,
unsigned int flags);
typedef struct _virInterfaceDriver virInterfaceDriver;
Index: src/libvirt.c
===================================================================
RCS file: /data/cvs/libvirt/src/libvirt.c,v
retrieving revision 1.211
diff -u -p -r1.211 libvirt.c
--- src/libvirt.c 25 May 2009 11:56:00 -0000 1.211
+++ src/libvirt.c 28 May 2009 16:32:54 -0000
@@ -472,7 +472,7 @@ virLibNetworkError(virNetworkPtr network
* Handle an error at the connection level
*/
static void
-virLibInterfaceError(virInterfacePtr interface, virErrorNumber error,
+virLibInterfaceError(virInterfacePtr iface, virErrorNumber error,
const char *info)
{
virConnectPtr conn = NULL;
@@ -483,7 +483,7 @@ virLibInterfaceError(virInterfacePtr int
errmsg = virErrorMsg(error, info);
if (error != VIR_ERR_INVALID_INTERFACE) {
- conn = interface->conn;
+ conn = iface->conn;
}
virRaiseError(conn, NULL, NULL, VIR_FROM_INTERFACE, error, VIR_ERR_ERROR,
errmsg, info, NULL, 0, 0, errmsg, info);
@@ -5485,17 +5485,17 @@ error:
* Returns the virConnectPtr or NULL in case of failure.
*/
virConnectPtr
-virInterfaceGetConnect (virInterfacePtr interface)
+virInterfaceGetConnect (virInterfacePtr iface)
{
- DEBUG("interface=%p", interface);
+ DEBUG("iface=%p", iface);
virResetLastError();
- if (!VIR_IS_CONNECTED_INTERFACE (interface)) {
+ if (!VIR_IS_CONNECTED_INTERFACE (iface)) {
virLibInterfaceError (NULL, VIR_ERR_INVALID_INTERFACE, __FUNCTION__);
return NULL;
}
- return interface->conn;
+ return iface->conn;
}
/**
@@ -5663,7 +5663,7 @@ error:
/**
* virInterfaceGetName:
- * @interface: a interface object
+ * @iface: a interface object
*
* Get the public name for that interface
*
@@ -5671,22 +5671,22 @@ error:
* its lifetime will be the same as the interface object.
*/
const char *
-virInterfaceGetName(virInterfacePtr interface)
+virInterfaceGetName(virInterfacePtr iface)
{
- DEBUG("interface=%p", interface);
+ DEBUG("iface=%p", iface);
virResetLastError();
- if (!VIR_IS_INTERFACE(interface)) {
+ if (!VIR_IS_INTERFACE(iface)) {
virLibInterfaceError(NULL, VIR_ERR_INVALID_INTERFACE, __FUNCTION__);
return (NULL);
}
- return (interface->name);
+ return (iface->name);
}
/**
* virInterfaceGetMACString:
- * @interface: a interface object
+ * @iface: a interface object
*
* Get the MAC for a interface as string. For more information about
* MAC see RFC4122.
@@ -5696,22 +5696,22 @@ virInterfaceGetName(virInterfacePtr inte
* will be the same as the interface object.
*/
const char *
-virInterfaceGetMACString(virInterfacePtr interface)
+virInterfaceGetMACString(virInterfacePtr iface)
{
- DEBUG("interface=%p", interface);
+ DEBUG("iface=%p", iface);
virResetLastError();
- if (!VIR_IS_INTERFACE(interface)) {
+ if (!VIR_IS_INTERFACE(iface)) {
virLibInterfaceError(NULL, VIR_ERR_INVALID_INTERFACE, __FUNCTION__);
return (NULL);
}
- return (interface->mac);
+ return (iface->mac);
}
/**
* virInterfaceGetXMLDesc:
- * @interface: a interface object
+ * @iface: a interface object
* @flags: and OR'ed set of extraction flags, not used yet
*
* Provide an XML description of the interface. The description may be reused
@@ -5721,27 +5721,27 @@ virInterfaceGetMACString(virInterfacePtr
* the caller must free() the returned value.
*/
char *
-virInterfaceGetXMLDesc(virInterfacePtr interface, unsigned int flags)
+virInterfaceGetXMLDesc(virInterfacePtr iface, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("interface=%p, flags=%d", interface, flags);
+ DEBUG("iface=%p, flags=%d", iface, flags);
virResetLastError();
- if (!VIR_IS_CONNECTED_INTERFACE(interface)) {
+ if (!VIR_IS_CONNECTED_INTERFACE(iface)) {
virLibInterfaceError(NULL, VIR_ERR_INVALID_INTERFACE, __FUNCTION__);
return (NULL);
}
if (flags != 0) {
- virLibInterfaceError(interface, VIR_ERR_INVALID_ARG, __FUNCTION__);
+ virLibInterfaceError(iface, VIR_ERR_INVALID_ARG, __FUNCTION__);
goto error;
}
- conn = interface->conn;
+ conn = iface->conn;
if (conn->interfaceDriver && conn->interfaceDriver->interfaceGetXMLDesc) {
char *ret;
- ret = conn->interfaceDriver->interfaceGetXMLDesc (interface, flags);
+ ret = conn->interfaceDriver->interfaceGetXMLDesc (iface, flags);
if (!ret)
goto error;
return ret;
@@ -5751,7 +5751,7 @@ virInterfaceGetXMLDesc(virInterfacePtr i
error:
/* Copy to connection error object for back compatability */
- virSetConnError(interface->conn);
+ virSetConnError(iface->conn);
return NULL;
}
@@ -5803,7 +5803,7 @@ error:
/**
* virInterfaceUndefine:
- * @interface: pointer to a defined interface
+ * @iface: pointer to a defined interface
*
* Undefine an interface, ie remove it from the config.
* This does not free the associated virInterfacePtr object.
@@ -5811,25 +5811,25 @@ error:
* Returns 0 in case of success, -1 in case of error
*/
int
-virInterfaceUndefine(virInterfacePtr interface) {
+virInterfaceUndefine(virInterfacePtr iface) {
virConnectPtr conn;
- DEBUG("interface=%p", interface);
+ DEBUG("iface=%p", iface);
virResetLastError();
- if (!VIR_IS_CONNECTED_INTERFACE(interface)) {
+ if (!VIR_IS_CONNECTED_INTERFACE(iface)) {
virLibInterfaceError(NULL, VIR_ERR_INVALID_INTERFACE, __FUNCTION__);
return (-1);
}
- conn = interface->conn;
+ conn = iface->conn;
if (conn->flags & VIR_CONNECT_RO) {
- virLibInterfaceError(interface, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ virLibInterfaceError(iface, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
goto error;
}
if (conn->interfaceDriver && conn->interfaceDriver->interfaceUndefine) {
int ret;
- ret = conn->interfaceDriver->interfaceUndefine (interface);
+ ret = conn->interfaceDriver->interfaceUndefine (iface);
if (ret < 0)
goto error;
return ret;
@@ -5839,13 +5839,13 @@ virInterfaceUndefine(virInterfacePtr int
error:
/* Copy to connection error object for back compatability */
- virSetConnError(interface->conn);
+ virSetConnError(iface->conn);
return -1;
}
/**
* virInterfaceCreate:
- * @interface: pointer to a defined interface
+ * @iface: pointer to a defined interface
* @flags: and OR'ed set of extraction flags, not used yet
*
* Activate an interface (ie call "ifup")
@@ -5853,26 +5853,26 @@ error:
* Returns 0 in case of success, -1 in case of error
*/
int
-virInterfaceCreate(virInterfacePtr interface, unsigned int flags)
+virInterfaceCreate(virInterfacePtr iface, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("interface=%p, flags=%d", interface, flags);
+ DEBUG("iface=%p, flags=%d", iface, flags);
virResetLastError();
- if (!VIR_IS_CONNECTED_INTERFACE(interface)) {
+ if (!VIR_IS_CONNECTED_INTERFACE(iface)) {
virLibInterfaceError(NULL, VIR_ERR_INVALID_INTERFACE, __FUNCTION__);
return (-1);
}
- conn = interface->conn;
+ conn = iface->conn;
if (conn->flags & VIR_CONNECT_RO) {
- virLibInterfaceError(interface, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ virLibInterfaceError(iface, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
goto error;
}
if (conn->interfaceDriver && conn->interfaceDriver->interfaceCreate) {
int ret;
- ret = conn->interfaceDriver->interfaceCreate (interface, flags);
+ ret = conn->interfaceDriver->interfaceCreate (iface, flags);
if (ret < 0)
goto error;
return ret;
@@ -5882,13 +5882,13 @@ virInterfaceCreate(virInterfacePtr inter
error:
/* Copy to connection error object for back compatability */
- virSetConnError(interface->conn);
+ virSetConnError(iface->conn);
return -1;
}
/**
* virInterfaceDestroy:
- * @interface: an interface object
+ * @iface: an interface object
* @flags: and OR'ed set of extraction flags, not used yet
*
* deactivate an interface (ie call "ifdown")
@@ -5898,27 +5898,27 @@ error:
* Returns 0 in case of success and -1 in case of failure.
*/
int
-virInterfaceDestroy(virInterfacePtr interface, unsigned int flags)
+virInterfaceDestroy(virInterfacePtr iface, unsigned int flags)
{
virConnectPtr conn;
- DEBUG("interface=%p, flags=%d", interface, flags);
+ DEBUG("iface=%p, flags=%d", iface, flags);
virResetLastError();
- if (!VIR_IS_CONNECTED_INTERFACE(interface)) {
+ if (!VIR_IS_CONNECTED_INTERFACE(iface)) {
virLibInterfaceError(NULL, VIR_ERR_INVALID_INTERFACE, __FUNCTION__);
return (-1);
}
- conn = interface->conn;
+ conn = iface->conn;
if (conn->flags & VIR_CONNECT_RO) {
- virLibInterfaceError(interface, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
+ virLibInterfaceError(iface, VIR_ERR_OPERATION_DENIED, __FUNCTION__);
goto error;
}
if (conn->interfaceDriver && conn->interfaceDriver->interfaceDestroy) {
int ret;
- ret = conn->interfaceDriver->interfaceDestroy (interface, flags);
+ ret = conn->interfaceDriver->interfaceDestroy (iface, flags);
if (ret < 0)
goto error;
return ret;
@@ -5928,13 +5928,13 @@ virInterfaceDestroy(virInterfacePtr inte
error:
/* Copy to connection error object for back compatability */
- virSetConnError(interface->conn);
+ virSetConnError(iface->conn);
return -1;
}
/**
* virInterfaceRef:
- * @interface: the interface to hold a reference on
+ * @iface: the interface to hold a reference on
*
* Increment the reference count on the interface. For each
* additional call to this method, there shall be a corresponding
@@ -5950,22 +5950,22 @@ error:
* Returns 0 in case of success, -1 in case of failure.
*/
int
-virInterfaceRef(virInterfacePtr interface)
+virInterfaceRef(virInterfacePtr iface)
{
- if ((!VIR_IS_CONNECTED_INTERFACE(interface))) {
+ if ((!VIR_IS_CONNECTED_INTERFACE(iface))) {
virLibConnError(NULL, VIR_ERR_INVALID_ARG, __FUNCTION__);
return(-1);
}
- virMutexLock(&interface->conn->lock);
- DEBUG("interface=%p refs=%d", interface, interface->refs);
- interface->refs++;
- virMutexUnlock(&interface->conn->lock);
+ virMutexLock(&iface->conn->lock);
+ DEBUG("iface=%p refs=%d", iface, iface->refs);
+ iface->refs++;
+ virMutexUnlock(&iface->conn->lock);
return 0;
}
/**
* virInterfaceFree:
- * @interface: a interface object
+ * @iface: a interface object
*
* Free the interface object. The interface itself is unaltered.
* The data structure is freed and should not be used thereafter.
@@ -5973,17 +5973,17 @@ virInterfaceRef(virInterfacePtr interfac
* Returns 0 in case of success and -1 in case of failure.
*/
int
-virInterfaceFree(virInterfacePtr interface)
+virInterfaceFree(virInterfacePtr iface)
{
- DEBUG("interface=%p", interface);
+ DEBUG("iface=%p", iface);
virResetLastError();
- if (!VIR_IS_CONNECTED_INTERFACE(interface)) {
+ if (!VIR_IS_CONNECTED_INTERFACE(iface)) {
virLibInterfaceError(NULL, VIR_ERR_INVALID_INTERFACE, __FUNCTION__);
return (-1);
}
- if (virUnrefInterface(interface) < 0)
+ if (virUnrefInterface(iface) < 0)
return (-1);
return(0);
}
Index: src/remote_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/remote_internal.c,v
retrieving revision 1.153
diff -u -p -r1.153 remote_internal.c
--- src/remote_internal.c 21 May 2009 13:50:56 -0000 1.153
+++ src/remote_internal.c 28 May 2009 16:32:54 -0000
@@ -212,7 +212,7 @@ static void errorf (virConnectPtr conn,
static void server_error (virConnectPtr conn, remote_error *err);
static virDomainPtr get_nonnull_domain (virConnectPtr conn, remote_nonnull_domain domain);
static virNetworkPtr get_nonnull_network (virConnectPtr conn, remote_nonnull_network network);
-static virInterfacePtr get_nonnull_interface (virConnectPtr conn, remote_nonnull_interface interface);
+static virInterfacePtr get_nonnull_interface (virConnectPtr conn, remote_nonnull_interface iface);
static virStoragePoolPtr get_nonnull_storage_pool (virConnectPtr conn, remote_nonnull_storage_pool pool);
static virStorageVolPtr get_nonnull_storage_vol (virConnectPtr conn, remote_nonnull_storage_vol vol);
static virNodeDevicePtr get_nonnull_node_device (virConnectPtr conn, remote_nonnull_node_device dev);
@@ -3876,7 +3876,7 @@ static virInterfacePtr
remoteInterfaceLookupByName (virConnectPtr conn,
const char *name)
{
- virInterfacePtr interface = NULL;
+ virInterfacePtr iface = NULL;
remote_interface_lookup_by_name_args args;
remote_interface_lookup_by_name_ret ret;
struct private_data *priv = conn->interfacePrivateData;
@@ -3891,19 +3891,19 @@ remoteInterfaceLookupByName (virConnectP
(xdrproc_t) xdr_remote_interface_lookup_by_name_ret, (char *) &ret) == -1)
goto done;
- interface = get_nonnull_interface (conn, ret.interface);
+ iface = get_nonnull_interface (conn, ret.iface);
xdr_free ((xdrproc_t) &xdr_remote_interface_lookup_by_name_ret, (char *) &ret);
done:
remoteDriverUnlock(priv);
- return interface;
+ return iface;
}
static virInterfacePtr
remoteInterfaceLookupByMACString (virConnectPtr conn,
const char *mac)
{
- virInterfacePtr interface = NULL;
+ virInterfacePtr iface = NULL;
remote_interface_lookup_by_mac_string_args args;
remote_interface_lookup_by_mac_string_ret ret;
struct private_data *priv = conn->interfacePrivateData;
@@ -3918,30 +3918,30 @@ remoteInterfaceLookupByMACString (virCon
(xdrproc_t) xdr_remote_interface_lookup_by_mac_string_ret, (char *) &ret) == -1)
goto done;
- interface = get_nonnull_interface (conn, ret.interface);
+ iface = get_nonnull_interface (conn, ret.iface);
xdr_free ((xdrproc_t) &xdr_remote_interface_lookup_by_mac_string_ret, (char *) &ret);
done:
remoteDriverUnlock(priv);
- return interface;
+ return iface;
}
static char *
-remoteInterfaceGetXMLDesc (virInterfacePtr interface,
+remoteInterfaceGetXMLDesc (virInterfacePtr iface,
unsigned int flags)
{
char *rv = NULL;
remote_interface_get_xml_desc_args args;
remote_interface_get_xml_desc_ret ret;
- struct private_data *priv = interface->conn->interfacePrivateData;
+ struct private_data *priv = iface->conn->interfacePrivateData;
remoteDriverLock(priv);
- make_nonnull_interface (&args.interface, interface);
+ make_nonnull_interface (&args.iface, iface);
args.flags = flags;
memset (&ret, 0, sizeof ret);
- if (call (interface->conn, priv, 0, REMOTE_PROC_INTERFACE_GET_XML_DESC,
+ if (call (iface->conn, priv, 0, REMOTE_PROC_INTERFACE_GET_XML_DESC,
(xdrproc_t) xdr_remote_interface_get_xml_desc_args, (char *) &args,
(xdrproc_t) xdr_remote_interface_get_xml_desc_ret, (char *) &ret) == -1)
goto done;
@@ -3959,7 +3959,7 @@ remoteInterfaceDefineXML (virConnectPtr
const char *xmlDesc,
unsigned int flags)
{
- virInterfacePtr interface = NULL;
+ virInterfacePtr iface = NULL;
remote_interface_define_xml_args args;
remote_interface_define_xml_ret ret;
struct private_data *priv = conn->interfacePrivateData;
@@ -3975,26 +3975,26 @@ remoteInterfaceDefineXML (virConnectPtr
(xdrproc_t) xdr_remote_interface_define_xml_ret, (char *) &ret) == -1)
goto done;
- interface = get_nonnull_interface (conn, ret.interface);
+ iface = get_nonnull_interface (conn, ret.iface);
xdr_free ((xdrproc_t) &xdr_remote_interface_define_xml_ret, (char *) &ret);
done:
remoteDriverUnlock(priv);
- return interface;
+ return iface;
}
static int
-remoteInterfaceUndefine (virInterfacePtr interface)
+remoteInterfaceUndefine (virInterfacePtr iface)
{
int rv = -1;
remote_interface_undefine_args args;
- struct private_data *priv = interface->conn->interfacePrivateData;
+ struct private_data *priv = iface->conn->interfacePrivateData;
remoteDriverLock(priv);
- make_nonnull_interface (&args.interface, interface);
+ make_nonnull_interface (&args.iface, iface);
- if (call (interface->conn, priv, 0, REMOTE_PROC_INTERFACE_UNDEFINE,
+ if (call (iface->conn, priv, 0, REMOTE_PROC_INTERFACE_UNDEFINE,
(xdrproc_t) xdr_remote_interface_undefine_args, (char *) &args,
(xdrproc_t) xdr_void, (char *) NULL) == -1)
goto done;
@@ -4007,19 +4007,19 @@ done:
}
static int
-remoteInterfaceCreate (virInterfacePtr interface,
+remoteInterfaceCreate (virInterfacePtr iface,
unsigned int flags)
{
int rv = -1;
remote_interface_create_args args;
- struct private_data *priv = interface->conn->interfacePrivateData;
+ struct private_data *priv = iface->conn->interfacePrivateData;
remoteDriverLock(priv);
- make_nonnull_interface (&args.interface, interface);
+ make_nonnull_interface (&args.iface, iface);
args.flags = flags;
- if (call (interface->conn, priv, 0, REMOTE_PROC_INTERFACE_CREATE,
+ if (call (iface->conn, priv, 0, REMOTE_PROC_INTERFACE_CREATE,
(xdrproc_t) xdr_remote_interface_create_args, (char *) &args,
(xdrproc_t) xdr_void, (char *) NULL) == -1)
goto done;
@@ -4032,19 +4032,19 @@ done:
}
static int
-remoteInterfaceDestroy (virInterfacePtr interface,
+remoteInterfaceDestroy (virInterfacePtr iface,
unsigned int flags)
{
int rv = -1;
remote_interface_destroy_args args;
- struct private_data *priv = interface->conn->interfacePrivateData;
+ struct private_data *priv = iface->conn->interfacePrivateData;
remoteDriverLock(priv);
- make_nonnull_interface (&args.interface, interface);
+ make_nonnull_interface (&args.iface, iface);
args.flags = flags;
- if (call (interface->conn, priv, 0, REMOTE_PROC_INTERFACE_DESTROY,
+ if (call (iface->conn, priv, 0, REMOTE_PROC_INTERFACE_DESTROY,
(xdrproc_t) xdr_remote_interface_destroy_args, (char *) &args,
(xdrproc_t) xdr_void, (char *) NULL) == -1)
goto done;
@@ -7256,9 +7256,9 @@ get_nonnull_network (virConnectPtr conn,
}
static virInterfacePtr
-get_nonnull_interface (virConnectPtr conn, remote_nonnull_interface interface)
+get_nonnull_interface (virConnectPtr conn, remote_nonnull_interface iface)
{
- return virGetInterface (conn, interface.name, interface.mac);
+ return virGetInterface (conn, iface.name, iface.mac);
}
static virStoragePoolPtr
Index: tests/testutils.c
===================================================================
RCS file: /data/cvs/libvirt/tests/testutils.c,v
retrieving revision 1.28
diff -u -p -r1.28 testutils.c
--- tests/testutils.c 21 May 2009 14:22:51 -0000 1.28
+++ tests/testutils.c 28 May 2009 16:32:54 -0000
@@ -18,7 +18,9 @@
#ifndef WIN32
#include <sys/wait.h>
#endif
+#ifdef HAVE_REGEX_H
#include <regex.h>
+#endif
#include <unistd.h>
#include <string.h>
#include <fcntl.h>
@@ -460,6 +462,7 @@ cleanup:
}
+#ifdef HAVE_REGEX_H
int virtTestClearLineRegex(const char *pattern,
char *str)
{
@@ -503,3 +506,10 @@ int virtTestClearLineRegex(const char *p
return 0;
}
+#else
+int virtTestClearLineRegex(const char *pattern ATTRIBUTE_UNUSED,
+ char *str ATTRIBUTE_UNUSED)
+{
+ return 0;
+}
+#endif
--
|: Red Hat, Engineering, London -o- http://people.redhat.com/berrange/ :|
|: http://libvirt.org -o- http://virt-manager.org -o- http://ovirt.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|
15 years, 7 months
[libvirt] [PATCH] virsh: Use consistent spacing for net-list
by Cole Robinson
There is different spacing when listing active vs. inactive networks. Ex:
Name State Autostart
-----------------------------------------
default active yes
xxxxxx inactive no
Signed-off-by: Cole Robinson <crobinso(a)redhat.com>
---
src/virsh.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/src/virsh.c b/src/virsh.c
index fe4e8e6..e6241e6 100644
--- a/src/virsh.c
+++ b/src/virsh.c
@@ -2798,7 +2798,7 @@ cmdNetworkList(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
else
autostartStr = autostart ? "yes" : "no";
- vshPrint(ctl, "%-20s %s %s\n",
+ vshPrint(ctl, "%-20s %-10s %-10s\n",
inactiveNames[i],
_("inactive"),
autostartStr);
--
1.6.0.6
15 years, 7 months