Devel
Threads by month
- ----- 2026 -----
- April
- March
- February
- January
- ----- 2025 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2024 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2023 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2022 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2021 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2020 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2019 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2018 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2017 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2016 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2015 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2014 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2013 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2012 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2011 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2010 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2009 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2008 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2007 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2006 -----
- December
- November
- October
- September
- August
- July
- June
- May
- April
- March
- February
- January
- ----- 2005 -----
- December
- 17 participants
- 40169 discussions
The driver function table in the VBox driver is currently using named
struct member initializers. We previously removed all these from other
drivers, so we have a clearer indication of missing APIs in each driver.
This patch updates VBox to follow the preferred style
Daniel
diff -r f639344b66bc src/vbox/vbox_tmpl.c
--- a/src/vbox/vbox_tmpl.c Thu May 28 11:36:37 2009 +0100
+++ b/src/vbox/vbox_tmpl.c Thu May 28 11:55:49 2009 +0100
@@ -4899,64 +4899,72 @@ cleanup:
virDriver NAME(Driver) = {
VIR_DRV_VBOX,
"VBOX",
- .open = vboxOpen,
- .close = vboxClose,
- .supports_feature = NULL,
- .type = NULL,
- .version = vboxGetVersion,
- .getHostname = vboxGetHostname,
- .getMaxVcpus = vboxGetMaxVcpus,
- .nodeGetInfo = nodeGetInfo,
- .getCapabilities = vboxGetCapabilities,
- .listDomains = vboxListDomains,
- .numOfDomains = vboxNumOfDomains,
- .domainCreateXML = vboxDomainCreateXML,
- .domainLookupByID = vboxDomainLookupByID,
- .domainLookupByUUID = vboxDomainLookupByUUID,
- .domainLookupByName = vboxDomainLookupByName,
- .domainSuspend = vboxDomainSuspend,
- .domainResume = vboxDomainResume,
- .domainShutdown = vboxDomainShutdown,
- .domainReboot = vboxDomainReboot,
- .domainDestroy = vboxDomainDestroy,
- .domainGetOSType = vboxDomainGetOSType,
- .domainGetMaxMemory = NULL,
- .domainSetMaxMemory = NULL,
- .domainSetMemory = vboxDomainSetMemory,
- .domainGetInfo = vboxDomainGetInfo,
- .domainSave = vboxDomainSave,
- .domainRestore = NULL,
- .domainCoreDump = NULL,
- .domainSetVcpus = NULL,
- .domainPinVcpu = NULL,
- .domainGetVcpus = NULL,
- .domainGetMaxVcpus = NULL,
- .domainDumpXML = vboxDomainDumpXML,
- .listDefinedDomains = vboxListDefinedDomains,
- .numOfDefinedDomains = vboxNumOfDefinedDomains,
- .domainCreate = vboxDomainCreate,
- .domainDefineXML = vboxDomainDefineXML,
- .domainUndefine = vboxDomainUndefine,
- .domainAttachDevice = vboxDomainAttachDevice,
- .domainDetachDevice = vboxDomainDetachDevice,
- .domainGetAutostart = NULL,
- .domainSetAutostart = NULL,
- .domainGetSchedulerType = NULL,
- .domainGetSchedulerParameters = NULL,
- .domainSetSchedulerParameters = NULL,
- .domainMigratePrepare = NULL,
- .domainMigratePerform = NULL,
- .domainMigrateFinish = NULL,
- .domainBlockStats = NULL,
- .domainInterfaceStats = NULL,
- .domainBlockPeek = NULL,
- .domainMemoryPeek = NULL,
- .nodeGetCellsFreeMemory = NULL,
- .getFreeMemory = NULL,
- .domainEventRegister = NULL,
- .domainEventDeregister = NULL,
- .domainMigratePrepare2 = NULL,
- .domainMigrateFinish2 = NULL,
+ vboxOpen, /* open */
+ vboxClose, /* close */
+ NULL, /* supports_feature */
+ NULL, /* type */
+ vboxGetVersion, /* version */
+ vboxGetHostname, /* getHostname */
+ vboxGetMaxVcpus, /* getMaxVcpus */
+ nodeGetInfo, /* nodeGetInfo */
+ vboxGetCapabilities, /* getCapabilities */
+ vboxListDomains, /* listDomains */
+ vboxNumOfDomains, /* numOfDomains */
+ vboxDomainCreateXML, /* domainCreateXML */
+ vboxDomainLookupByID, /* domainLookupByID */
+ vboxDomainLookupByUUID, /* domainLookupByUUID */
+ vboxDomainLookupByName, /* domainLookupByName */
+ vboxDomainSuspend, /* domainSuspend */
+ vboxDomainResume, /* domainResume */
+ vboxDomainShutdown, /* domainShutdown */
+ vboxDomainReboot, /* domainReboot */
+ vboxDomainDestroy, /* domainDestroy */
+ vboxDomainGetOSType, /* domainGetOSType */
+ NULL, /* domainGetMaxMemory */
+ NULL, /* domainSetMaxMemory */
+ vboxDomainSetMemory, /* domainSetMemory */
+ vboxDomainGetInfo, /* domainGetInfo */
+ vboxDomainSave, /* domainSave */
+ NULL, /* domainRestore */
+ NULL, /* domainCoreDump */
+ NULL, /* domainSetVcpus */
+ NULL, /* domainPinVcpu */
+ NULL, /* domainGetVcpus */
+ NULL, /* domainGetMaxVcpus */
+ NULL, /* domainGetSecurityLabel */
+ NULL, /* nodeGetSecurityModel */
+ vboxDomainDumpXML, /* domainDumpXML */
+ NULL, /* domainXmlFromNative */
+ NULL, /* domainXmlToNative */
+ vboxListDefinedDomains, /* listDefinedDomains */
+ vboxNumOfDefinedDomains, /* numOfDefinedDomains */
+ vboxDomainCreate, /* domainCreate */
+ vboxDomainDefineXML, /* domainDefineXML */
+ vboxDomainUndefine, /* domainUndefine */
+ vboxDomainAttachDevice, /* domainAttachDevice */
+ vboxDomainDetachDevice, /* domainDetachDevice */
+ NULL, /* domainGetAutostart */
+ NULL, /* domainSetAutostart */
+ NULL, /* domainGetSchedulerType */
+ NULL, /* domainGetSchedulerParameters */
+ NULL, /* domainSetSchedulerParameters */
+ NULL, /* domainMigratePrepare */
+ NULL, /* domainMigratePerform */
+ NULL, /* domainMigrateFinish */
+ NULL, /* domainBlockStats */
+ NULL, /* domainInterfaceStats */
+ NULL, /* domainBlockPeek */
+ NULL, /* domainMemoryPeek */
+ NULL, /* nodeGetCellsFreeMemory */
+ NULL, /* getFreeMemory */
+ NULL, /* domainEventRegister */
+ NULL, /* domainEventDeregister */
+ NULL, /* domainMigratePrepare2 */
+ NULL, /* domainMigrateFinish2 */
+ NULL, /* nodeDeviceDettach */
+ NULL, /* nodeDeviceReAttach */
+ NULL, /* nodeDeviceReset */
+
};
virNetworkDriver NAME(NetworkDriver) = {
--
|: 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 :|
3
2
02 Jun '09
The LXC driver is missing a implementation of the capabilities
API, even though it has its capabilities object available in its
internally struct. This patch exposes the capabilities, and also
hooks up the shared NUMA APIs.
Daniel
diff -r 0d3150636e3e src/lxc_driver.c
--- a/src/lxc_driver.c Thu May 28 11:33:16 2009 +0100
+++ b/src/lxc_driver.c Thu May 28 11:36:37 2009 +0100
@@ -47,6 +47,7 @@
#include "veth.h"
#include "event.h"
#include "cgroup.h"
+#include "nodeinfo.h"
#define VIR_FROM_THIS VIR_FROM_LXC
@@ -115,6 +116,19 @@ static int lxcClose(virConnectPtr conn)
return 0;
}
+static char *lxcGetCapabilities(virConnectPtr conn) {
+ lxc_driver_t *driver = conn->privateData;
+ char *xml;
+
+ lxcDriverLock(driver);
+ if ((xml = virCapabilitiesFormatXML(driver->caps)) == NULL)
+ virReportOOMError(conn);
+ lxcDriverUnlock(driver);
+
+ return xml;
+}
+
+
static virDomainPtr lxcDomainLookupByID(virConnectPtr conn,
int id)
{
@@ -1429,8 +1443,8 @@ static virDriver lxcDriver = {
lxcVersion, /* version */
lxcGetHostname, /* getHostname */
NULL, /* getMaxVcpus */
- NULL, /* nodeGetInfo */
- NULL, /* getCapabilities */
+ nodeGetInfo, /* nodeGetInfo */
+ lxcGetCapabilities, /* getCapabilities */
lxcListDomains, /* listDomains */
lxcNumDomains, /* numOfDomains */
lxcDomainCreateAndStart, /* domainCreateXML */
@@ -1478,8 +1492,8 @@ static virDriver lxcDriver = {
NULL, /* domainInterfaceStats */
NULL, /* domainBlockPeek */
NULL, /* domainMemoryPeek */
- NULL, /* nodeGetCellsFreeMemory */
- NULL, /* getFreeMemory */
+ nodeGetCellsFreeMemory, /* nodeGetCellsFreeMemory */
+ nodeGetFreeMemory, /* getFreeMemory */
NULL, /* domainEventRegister */
NULL, /* domainEventDeregister */
NULL, /* domainMigratePrepare2 */
--
|: 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 :|
2
1
02 Jun '09
This patch adds support for bridge, virtual network, multicast and user-mode
networking in the User Mode Linux driver. You can't pass an open TAP device
file descriptor to UML, so we also extend the bridge.c file to supporting
creation & deletion of persistent TAP devices.
Daniel
diff --git a/src/bridge.c b/src/bridge.c
--- a/src/bridge.c
+++ b/src/bridge.c
@@ -451,8 +451,11 @@ brProbeVnetHdr(int tapfd)
*
* This function creates a new tap device on a bridge. @ifname can be either
* a fixed name or a name template with '%d' for dynamic name allocation.
- * in either case the final name for the bridge will be stored in @ifname
- * and the associated file descriptor in @tapfd.
+ * in either case the final name for the bridge will be stored in @ifname.
+ * If the @tapfd parameter is supplied, the open tap device file
+ * descriptor will be returned, otherwise the TAP device will be made
+ * persistent and closed. The caller must use brDeleteTap to remove
+ * a persistent TAP devices when it is no longer needed.
*
* Returns 0 in case of success or an errno code in case of failure.
*/
@@ -465,7 +468,7 @@ brAddTap(brControl *ctl,
{
int id, subst, fd;
- if (!ctl || !ctl->fd || !bridge || !ifname || !tapfd)
+ if (!ctl || !ctl->fd || !bridge || !ifname)
return EINVAL;
subst = id = 0;
@@ -520,10 +523,14 @@ brAddTap(brControl *ctl,
goto error;
if ((errno = brSetInterfaceUp(ctl, try.ifr_name, 1)))
goto error;
+ if (!tapfd &&
+ (errno = ioctl(fd, TUNSETPERSIST, 1)))
+ goto error;
VIR_FREE(*ifname);
if (!(*ifname = strdup(try.ifr_name)))
goto error;
- *tapfd = fd;
+ if (tapfd)
+ *tapfd = fd;
return 0;
}
@@ -535,6 +542,43 @@ brAddTap(brControl *ctl,
return errno;
}
+
+int brDeleteTap(brControl *ctl,
+ const char *ifname)
+{
+ struct ifreq try;
+ int len;
+ int fd;
+
+ if (!ctl || !ctl->fd || !ifname)
+ return EINVAL;
+
+ if ((fd = open("/dev/net/tun", O_RDWR)) < 0)
+ return errno;
+
+ memset(&try, 0, sizeof(struct ifreq));
+ try.ifr_flags = IFF_TAP|IFF_NO_PI;
+
+ len = strlen(ifname);
+ if (len >= BR_IFNAME_MAXLEN - 1) {
+ errno = EINVAL;
+ goto error;
+ }
+
+ strncpy(try.ifr_name, ifname, len);
+ try.ifr_name[len] = '\0';
+
+ if (ioctl(fd, TUNSETIFF, &try) == 0) {
+ if ((errno = ioctl(fd, TUNSETPERSIST, 0)))
+ goto error;
+ }
+
+ error:
+ close(fd);
+
+ return errno;
+}
+
/**
* brSetInterfaceUp:
diff --git a/src/bridge.h b/src/bridge.h
--- a/src/bridge.h
+++ b/src/bridge.h
@@ -60,11 +60,19 @@ int brDeleteInterface (brContr
const char *bridge,
const char *iface);
+enum {
+ BR_TAP_VNET_HDR = (1 << 0),
+ BR_TAP_PERSIST = (1 << 1),
+};
+
int brAddTap (brControl *ctl,
const char *bridge,
char **ifname,
- int vnet_hdr,
+ int features,
int *tapfd);
+
+int brDeleteTap (brControl *ctl,
+ const char *ifname);
int brSetInterfaceUp (brControl *ctl,
const char *ifname,
diff --git a/src/domain_conf.c b/src/domain_conf.c
--- a/src/domain_conf.c
+++ b/src/domain_conf.c
@@ -3146,6 +3146,7 @@ virDomainNetDefFormat(virConnectPtr conn
else
virBufferVSprintf(buf, " <source port='%d'/>\n",
def->data.socket.port);
+ break;
case VIR_DOMAIN_NET_TYPE_INTERNAL:
virBufferEscapeString(buf, " <source name='%s'/>\n",
diff --git a/src/libvirt_bridge.syms b/src/libvirt_bridge.syms
--- a/src/libvirt_bridge.syms
+++ b/src/libvirt_bridge.syms
@@ -8,6 +8,7 @@ brAddBridge;
brAddBridge;
brAddInterface;
brAddTap;
+brDeleteTap;
brDeleteBridge;
brHasBridge;
brInit;
diff --git a/src/uml_conf.c b/src/uml_conf.c
--- a/src/uml_conf.c
+++ b/src/uml_conf.c
@@ -44,6 +44,7 @@
#include "memory.h"
#include "nodeinfo.h"
#include "verify.h"
+#include "bridge.h"
#define VIR_FROM_THIS VIR_FROM_UML
@@ -90,6 +91,172 @@ virCapsPtr umlCapsInit(void) {
return NULL;
}
+
+static int
+umlConnectTapDevice(virConnectPtr conn,
+ virDomainNetDefPtr net,
+ const char *bridge)
+{
+ int tapfd = -1;
+ int err;
+ brControl *brctl = NULL;
+
+ if (!net->ifname ||
+ STRPREFIX(net->ifname, "vnet") ||
+ strchr(net->ifname, '%')) {
+ VIR_FREE(net->ifname);
+ if (!(net->ifname = strdup("vnet%d")))
+ goto no_memory;
+ }
+
+ if ((err = brInit(&brctl))) {
+ char ebuf[1024];
+ umlReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("cannot initialize bridge support: %s"),
+ virStrerror(err, ebuf, sizeof ebuf));
+ goto error;
+ }
+
+ if ((err = brAddTap(brctl, bridge,
+ &net->ifname, BR_TAP_PERSIST, &tapfd))) {
+ if (errno == ENOTSUP) {
+ /* In this particular case, give a better diagnostic. */
+ umlReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("Failed to add tap interface to bridge. "
+ "%s is not a bridge device"), bridge);
+ } else {
+ char ebuf[1024];
+ umlReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("Failed to add tap interface '%s' "
+ "to bridge '%s' : %s"),
+ net->ifname, bridge, virStrerror(err, ebuf, sizeof ebuf));
+ }
+ goto error;
+ }
+ close(tapfd);
+
+ brShutdown(brctl);
+
+ return 0;
+
+no_memory:
+ virReportOOMError(conn);
+error:
+ brShutdown(brctl);
+ return -1;
+}
+
+static char *
+umlBuildCommandLineNet(virConnectPtr conn,
+ virDomainNetDefPtr def,
+ int idx)
+{
+ char *ret;
+ virBuffer buf = VIR_BUFFER_INITIALIZER;
+
+ /* General format: ethNN=type,options */
+
+ virBufferVSprintf(&buf, "eth%d=", idx);
+
+ switch (def->type) {
+ case VIR_DOMAIN_NET_TYPE_USER:
+ /* ethNNN=slirp,macaddr */
+ virBufferAddLit(&buf, "slirp");
+ break;
+
+ case VIR_DOMAIN_NET_TYPE_ETHERNET:
+ /* ethNNN=tuntap,tapname,macaddr,gateway */
+ virBufferAddLit(&buf, "tuntap");
+ if (def->data.ethernet.ipaddr) {
+ umlReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s",
+ _("IP address not supported for ethernet inteface"));
+ goto error;
+ }
+ if (def->data.ethernet.script) {
+ umlReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s",
+ _("script execution not supported for ethernet inteface"));
+ goto error;
+ }
+ break;
+
+ case VIR_DOMAIN_NET_TYPE_SERVER:
+ umlReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s",
+ _("TCP server networking type not supported"));
+ goto error;
+
+ case VIR_DOMAIN_NET_TYPE_CLIENT:
+ umlReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s",
+ _("TCP client networking type not supported"));
+ goto error;
+
+ case VIR_DOMAIN_NET_TYPE_MCAST:
+ /* ethNNN=tuntap,macaddr,ipaddr,port */
+ virBufferAddLit(&buf, "mcast");
+ break;
+
+ case VIR_DOMAIN_NET_TYPE_NETWORK:
+ {
+ char *bridge;
+ virNetworkPtr network = virNetworkLookupByName(conn,
+ def->data.network.name);
+ if (!network) {
+ umlReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("Network '%s' not found"),
+ def->data.network.name);
+ goto error;
+ }
+ bridge = virNetworkGetBridgeName(network);
+ virNetworkFree(network);
+ if (bridge == NULL) {
+ goto error;
+ }
+
+ if (umlConnectTapDevice(conn, def, bridge) < 0) {
+ VIR_FREE(bridge);
+ goto error;
+ }
+
+ /* ethNNN=tuntap,tapname,macaddr,gateway */
+ virBufferVSprintf(&buf, "tuntap,%s", def->ifname);
+ break;
+ }
+
+ case VIR_DOMAIN_NET_TYPE_BRIDGE:
+ if (umlConnectTapDevice(conn, def, def->data.bridge.brname) < 0)
+ goto error;
+
+ /* ethNNN=tuntap,tapname,macaddr,gateway */
+ virBufferVSprintf(&buf, "tuntap,%s", def->ifname);
+ break;
+
+ case VIR_DOMAIN_NET_TYPE_INTERNAL:
+ umlReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR, "%s",
+ _("internal networking type not supported"));
+ goto error;
+ }
+
+ virBufferVSprintf(&buf, ",%02x:%02x:%02x:%02x:%02x:%02x",
+ def->mac[0], def->mac[1], def->mac[2],
+ def->mac[3], def->mac[4], def->mac[5]);
+
+ if (def->type == VIR_DOMAIN_NET_TYPE_MCAST) {
+ virBufferVSprintf(&buf, ",%s,%d",
+ def->data.socket.address,
+ def->data.socket.port);
+ }
+
+ if (virBufferError(&buf)) {
+ virReportOOMError(conn);
+ return NULL;
+ }
+
+ return virBufferContentAndReset(&buf);
+
+error:
+ ret = virBufferContentAndReset(&buf);
+ VIR_FREE(ret);
+ return NULL;
+}
static char *
umlBuildCommandLineChr(virConnectPtr conn,
@@ -166,9 +333,8 @@ int umlBuildCommandLine(virConnectPtr co
struct uml_driver *driver ATTRIBUTE_UNUSED,
virDomainObjPtr vm,
const char ***retargv,
- const char ***retenv,
- int **tapfds,
- int *ntapfds) {
+ const char ***retenv)
+{
int i, j;
char memory[50];
struct utsname ut;
@@ -277,6 +443,13 @@ int umlBuildCommandLine(virConnectPtr co
ADD_ARG_PAIR(disk->dst, disk->src);
}
+ for (i = 0 ; i < vm->def->nnets ; i++) {
+ char *ret = umlBuildCommandLineNet(conn, vm->def->nets[i], i);
+ if (!ret)
+ goto error;
+ ADD_ARG(ret);
+ }
+
for (i = 0 ; i < UML_MAX_CHAR_DEVICE ; i++) {
char *ret;
if (i == 0 && vm->def->console)
@@ -311,13 +484,7 @@ int umlBuildCommandLine(virConnectPtr co
no_memory:
virReportOOMError(conn);
error:
- if (tapfds &&
- *tapfds) {
- for (i = 0; i < *ntapfds; i++)
- close((*tapfds)[i]);
- VIR_FREE(*tapfds);
- *ntapfds = 0;
- }
+
if (qargv) {
for (i = 0 ; i < qargc ; i++)
VIR_FREE((qargv)[i]);
diff --git a/src/uml_conf.h b/src/uml_conf.h
--- a/src/uml_conf.h
+++ b/src/uml_conf.h
@@ -70,8 +70,6 @@ int umlBuildCommandLine (v
struct uml_driver *driver,
virDomainObjPtr dom,
const char ***retargv,
- const char ***retenv,
- int **tapfds,
- int *ntapfds);
+ const char ***retenv);
#endif /* __UML_CONF_H */
diff --git a/src/uml_driver.c b/src/uml_driver.c
--- a/src/uml_driver.c
+++ b/src/uml_driver.c
@@ -715,6 +721,35 @@ error:
return -1;
}
+
+static int umlCleanupTapDevices(virConnectPtr conn ATTRIBUTE_UNUSED,
+ virDomainObjPtr vm) {
+ int i;
+ int err;
+ int ret = 0;
+ brControl *brctl = NULL;
+ VIR_ERROR0("Cleanup tap");
+ if (brInit(&brctl) < 0)
+ return -1;
+
+ for (i = 0 ; i < vm->def->nnets ; i++) {
+ virDomainNetDefPtr def = vm->def->nets[i];
+
+ if (def->type != VIR_DOMAIN_NET_TYPE_BRIDGE &&
+ def->type != VIR_DOMAIN_NET_TYPE_NETWORK)
+ continue;
+
+ VIR_ERROR("Cleanup '%s'", def->ifname);
+ err = brDeleteTap(brctl, def->ifname);
+ if (err) {
+ VIR_ERROR("Cleanup failed %d", err);
+ ret = -1;
+ }
+ }
+ VIR_ERROR0("Cleanup tap done");
+ brShutdown(brctl);
+ return ret;
+}
static int umlStartVMDaemon(virConnectPtr conn,
struct uml_driver *driver,
@@ -726,8 +761,6 @@ static int umlStartVMDaemon(virConnectPt
char *logfile;
int logfd = -1;
struct stat sb;
- int *tapfds = NULL;
- int ntapfds = 0;
fd_set keepfd;
char ebuf[1024];
@@ -786,9 +819,9 @@ static int umlStartVMDaemon(virConnectPt
}
if (umlBuildCommandLine(conn, driver, vm,
- &argv, &progenv,
- &tapfds, &ntapfds) < 0) {
+ &argv, &progenv) < 0) {
close(logfd);
+ umlCleanupTapDevices(conn, vm);
return -1;
}
@@ -818,9 +851,6 @@ static int umlStartVMDaemon(virConnectPt
vm->monitor = -1;
- for (i = 0 ; i < ntapfds ; i++)
- FD_SET(tapfds[i], &keepfd);
-
ret = virExecDaemonize(conn, argv, progenv, &keepfd, &pid,
-1, &logfd, &logfd,
0, NULL, NULL, NULL);
@@ -834,15 +864,14 @@ static int umlStartVMDaemon(virConnectPt
VIR_FREE(progenv[i]);
VIR_FREE(progenv);
- if (tapfds) {
- for (i = 0 ; i < ntapfds ; i++) {
- close(tapfds[i]);
- }
- VIR_FREE(tapfds);
- }
+ if (ret < 0)
+ umlCleanupTapDevices(conn, vm);
/* NB we don't mark it running here - we do that async
with inotify */
+ /* XXX what if someone else tries to start it again
+ before we get the inotification ? Sounds like
+ trouble.... */
return ret;
}
@@ -874,6 +901,8 @@ static void umlShutdownVMDaemon(virConne
vm->state = VIR_DOMAIN_SHUTOFF;
VIR_FREE(vm->vcpupids);
vm->nvcpupids = 0;
+
+ umlCleanupTapDevices(conn, vm);
if (vm->newDef) {
virDomainDefFree(vm->def);
--
|: 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 :|
2
1
There's a number of annoying bugs in the user mode linux driver startup
code. This patch fixes lots of them. We failed to check umlMonitorCommand
for error, leading to a NULL de-reference due to another bug in that
function. This patch also checks if 'res' is NULL before de-referenceing
it, just in case. In the code for handling inotify delete events, we
duplicated alot of the umlShutdownVMDaemon code, but forgot to close
the monitor. This patches makes it just call umlShutdownVMDaemon directly.
In one place where we spin in a usleep loop, we forgot to increment our
retries counter, making it spin forever. Finally, switch to virKillProcess
and make the latter also avoids pid==1, since I can't imagine a time
where we'd ever want to kill 'init' :-)
Daniel
diff --git a/src/uml_driver.c b/src/uml_driver.c
--- a/src/uml_driver.c
+++ b/src/uml_driver.c
@@ -166,9 +166,10 @@ umlIdentifyOneChrPTY(virConnectPtr conn,
return -1;
}
requery:
- umlMonitorCommand(NULL, driver, dom, cmd, &res);
+ if (umlMonitorCommand(NULL, driver, dom, cmd, &res) < 0)
+ return -1;
- if (STRPREFIX(res, "pts:")) {
+ if (res && STRPREFIX(res, "pts:")) {
VIR_FREE(def->data.file.path);
if ((def->data.file.path = strdup(res + 4)) == NULL) {
virReportOOMError(conn);
@@ -176,7 +177,7 @@ requery:
VIR_FREE(cmd);
return -1;
}
- } else if (STRPREFIX(res, "pts")) {
+ } else if (!res || STRPREFIX(res, "pts")) {
/* It can take a while to startup, so retry for
upto 5 seconds */
/* XXX should do this in a better non-blocking
@@ -263,19 +264,15 @@ reread:
}
if (e->mask & IN_DELETE) {
+ VIR_DEBUG("Got inotify domain shutdown '%s'", name);
if (!virDomainIsActive(dom)) {
virDomainObjUnlock(dom);
continue;
}
- dom->def->id = -1;
- dom->pid = -1;
- if (dom->newDef) {
- virDomainDefFree(dom->def);
- dom->def = dom->newDef;
- }
- dom->state = VIR_DOMAIN_SHUTOFF;
+ umlShutdownVMDaemon(NULL, driver, dom);
} else if (e->mask & (IN_CREATE | IN_MODIFY)) {
+ VIR_DEBUG("Got inotify domain startup '%s'", name);
if (virDomainIsActive(dom)) {
virDomainObjUnlock(dom);
continue;
@@ -289,11 +286,13 @@ reread:
dom->def->id = driver->nextvmid++;
dom->state = VIR_DOMAIN_RUNNING;
- if (umlOpenMonitor(NULL, driver, dom) < 0)
+ if (umlOpenMonitor(NULL, driver, dom) < 0) {
+ VIR_WARN0("Could not open monitor for new domain");
umlShutdownVMDaemon(NULL, driver, dom);
-
- if (umlIdentifyChrPTY(NULL, driver, dom) < 0)
+ } else if (umlIdentifyChrPTY(NULL, driver, dom) < 0) {
+ VIR_WARN0("Could not identify charater devices for new domain");
umlShutdownVMDaemon(NULL, driver, dom);
+ }
}
virDomainObjUnlock(dom);
}
@@ -383,6 +382,7 @@ umlStartup(void) {
goto error;
}
+ VIR_INFO("Adding inotify watch on %s", uml_driver->monitorDir);
if (inotify_add_watch(uml_driver->inotifyFD,
uml_driver->monitorDir,
IN_CREATE | IN_MODIFY | IN_DELETE) < 0) {
@@ -595,10 +595,11 @@ static int umlOpenMonitor(virConnectPtr
if (umlMonitorAddress(conn, driver, vm, &addr) < 0)
return -1;
+ VIR_DEBUG("Dest address for monitor is '%s'", addr.sun_path);
restat:
if (stat(addr.sun_path, &sb) < 0) {
if (errno == ENOENT &&
- retries < 50) {
+ retries++ < 50) {
usleep(1000 * 100);
goto restat;
}
@@ -612,7 +613,8 @@ restat:
}
memset(addr.sun_path, 0, sizeof addr.sun_path);
- sprintf(addr.sun_path + 1, "%u", getpid());
+ sprintf(addr.sun_path + 1, "libvirt-uml-%u", vm->pid);
+ VIR_DEBUG("Reply address for monitor is '%s'", addr.sun_path+1);
if (bind(vm->monitor, (struct sockaddr *)&addr, sizeof addr) < 0) {
virReportSystemError(conn, errno,
"%s", _("cannot bind socket"));
@@ -656,6 +658,8 @@ static int umlMonitorCommand(virConnectP
int retlen = 0, ret = 0;
struct sockaddr_un addr;
unsigned int addrlen;
+
+ VIR_DEBUG("Run command '%s'", cmd);
*reply = NULL;
@@ -706,6 +710,8 @@ static int umlMonitorCommand(virConnectP
} while (res.extra);
+ VIR_DEBUG("Command reply is '%s'", NULLSTR(retdata));
+
*reply = retdata;
return ret;
@@ -852,12 +881,10 @@ static void umlShutdownVMDaemon(virConne
virDomainObjPtr vm)
{
int ret;
- if (!virDomainIsActive(vm) ||
- vm->pid <= 1)
+ if (!virDomainIsActive(vm))
return;
-
- kill(vm->pid, SIGTERM);
+ virKillProcess(vm->pid, SIGTERM);
if (vm->monitor != -1)
close(vm->monitor);
diff --git a/src/util.c b/src/util.c
--- a/src/util.c
+++ b/src/util.c
@@ -1680,7 +1680,7 @@ char *virGetHostname(void)
/* send signal to a single process */
int virKillProcess(pid_t pid, int sig)
{
- if (pid < 1) {
+ if (pid <= 1) {
errno = ESRCH;
return -1;
}
--
|: 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 :|
2
1
[libvirt] PATCH: Fix libvirt log initialization to not override environment
by Daniel P. Berrange 02 Jun '09
by Daniel P. Berrange 02 Jun '09
02 Jun '09
Witht he libvirtd daemon, if you start it up with LIBVIRT_LOG_OUTPUTS or
LIBVIRT_LOG_FILTERS set, then it'll initially use these settings for
logging, but then when it reads the config file it'll reset all logging
and ignore your environment variables. This is rather confusing ! This
quick fix makes it honour this env variables, if the config file has not
got explicit overrides.
Daniel
diff --git a/qemud/qemud.c b/qemud/qemud.c
--- a/qemud/qemud.c
+++ b/qemud/qemud.c
@@ -2482,6 +2482,11 @@ qemudSetLogging(virConfPtr conf, const c
/* there is no default filters */
GET_CONF_STR (conf, filename, log_filters);
+ if (!log_filters) {
+ debugEnv = getenv("LIBVIRT_LOG_FILTERS");
+ if (debugEnv)
+ log_filters = strdup(debugEnv);
+ }
virLogParseFilters(log_filters);
/*
@@ -2489,7 +2494,12 @@ qemudSetLogging(virConfPtr conf, const c
* all logs to stderr if not running as daemon
*/
GET_CONF_STR (conf, filename, log_outputs);
- if (log_outputs == NULL) {
+ if (!log_outputs) {
+ debugEnv = getenv("LIBVIRT_LOG_OUTPUTS");
+ if (debugEnv)
+ log_outputs = strdup(debugEnv);
+ }
+ if (!log_outputs) {
if (godaemon) {
char *tmp = NULL;
if (virAsprintf (&tmp, "%d:syslog:libvirtd", log_level) < 0)
@@ -2499,8 +2509,9 @@ qemudSetLogging(virConfPtr conf, const c
} else {
virLogParseOutputs("0:stderr:libvirtd");
}
- } else
+ } else {
virLogParseOutputs(log_outputs);
+ }
ret = 0;
free_and_fail:
--
|: 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 :|
2
1
Here is a new version of the NPIV support incorporating everybody's
comments. I think it should be ready to go in at this point.
Dave
3
3
This patch is preparing the way for future work on allowing the libvirtd
daemon to run as a less-privileged user ID. The idea is that we will
switch from 'root' to 'libvirtd', but use Linux capabilties to keep the
handful of higher privileges we need for our work. Thus any code which
does a check of 'getuid() == 0' is guarenteed to break [1].
The way this patch approaches this problem, is to change the driver
initialization function virStateInitialize() to have it be passed in a
'int privileged' flag from the libvirtd daemon. Each driver is updated
to record this flag, and use it for checks where needed. The only real
exception is the Xen driver, where we simply check access(2) against
the file we need to open.
[1] Technically this is already broken on Solaris, since they already
change user id
qemud/qemud.c | 39 ++++++++++++++++++++++-----------------
qemud/qemud.h | 2 ++
src/driver.h | 2 +-
src/libvirt.c | 4 ++--
src/libvirt_internal.h | 2 +-
src/lxc_driver.c | 25 +++----------------------
src/network_driver.c | 4 ++--
src/node_device_devkit.c | 2 +-
src/node_device_hal.c | 2 +-
src/qemu_conf.h | 2 ++
src/qemu_driver.c | 37 +++++++++++++++++++------------------
src/remote_internal.c | 2 +-
src/storage_driver.c | 6 +++---
src/uml_conf.h | 2 ++
src/uml_driver.c | 18 +++++++++---------
src/xen_internal.c | 2 +-
src/xen_unified.c | 2 +-
17 files changed, 73 insertions(+), 80 deletions(-)
Daniel
diff -r 5e3b5d1f91c2 qemud/qemud.c
--- a/qemud/qemud.c Thu May 21 16:21:20 2009 +0100
+++ b/qemud/qemud.c Thu May 21 16:27:16 2009 +0100
@@ -112,8 +112,6 @@ static int unix_sock_ro_mask = 0666;
#else
-#define SYSTEM_UID 0
-
static gid_t unix_sock_gid = 0; /* Only root by default */
static int unix_sock_rw_mask = 0700; /* Allow user only */
static int unix_sock_ro_mask = 0777; /* Allow world */
@@ -512,7 +510,7 @@ static int qemudListenUnix(struct qemud_
oldgrp = getgid();
oldmask = umask(readonly ? ~unix_sock_ro_mask : ~unix_sock_rw_mask);
- if (getuid() == 0)
+ if (server->privileged)
setgid(unix_sock_gid);
if (bind(sock->fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
@@ -521,7 +519,7 @@ static int qemudListenUnix(struct qemud_
goto cleanup;
}
umask(oldmask);
- if (getuid() == 0)
+ if (server->privileged)
setgid(oldgrp);
if (listen(sock->fd, 30) < 0) {
@@ -696,7 +694,6 @@ static int qemudInitPaths(struct qemud_s
char *roSockname,
int maxlen)
{
- uid_t uid = geteuid();
char *sock_dir;
char *dir_prefix = NULL;
int ret = -1;
@@ -706,7 +703,7 @@ static int qemudInitPaths(struct qemud_s
sock_dir = unix_sock_dir;
else {
sock_dir = sockname;
- if (uid == SYSTEM_UID) {
+ if (server->privileged) {
dir_prefix = strdup (LOCAL_STATE_DIR);
if (dir_prefix == NULL) {
virReportOOMError(NULL);
@@ -716,6 +713,7 @@ static int qemudInitPaths(struct qemud_s
dir_prefix) >= maxlen)
goto snprintf_error;
} else {
+ uid_t uid = geteuid();
dir_prefix = virGetUserDirectory(NULL, uid);
if (dir_prefix == NULL) {
/* Do not diagnose here; virGetUserDirectory does that. */
@@ -733,7 +731,7 @@ static int qemudInitPaths(struct qemud_s
goto cleanup;
}
- if (uid == SYSTEM_UID) {
+ if (server->privileged) {
if (snprintf (sockname, maxlen, "%s/libvirt-sock",
sock_dir_prefix) >= maxlen
|| (snprintf (roSockname, maxlen, "%s/libvirt-sock-ro",
@@ -747,10 +745,10 @@ static int qemudInitPaths(struct qemud_s
goto snprintf_error;
}
- if (uid == SYSTEM_UID)
- server->logDir = strdup (LOCAL_STATE_DIR "/log/libvirt");
+ if (server->privileged)
+ server->logDir = strdup (LOCAL_STATE_DIR "/log/libvirt");
else
- virAsprintf(&server->logDir, "%s/.libvirt/log", dir_prefix);
+ virAsprintf(&server->logDir, "%s/.libvirt/log", dir_prefix);
if (server->logDir == NULL)
virReportOOMError(NULL);
@@ -786,6 +784,7 @@ static struct qemud_server *qemudInitial
VIR_FREE(server);
}
+ server->privileged = getuid() == 0 ? 1 : 0;
server->sigread = sigread;
if (virEventInit() < 0) {
@@ -844,7 +843,7 @@ static struct qemud_server *qemudInitial
virEventUpdateTimeoutImpl,
virEventRemoveTimeoutImpl);
- virStateInitialize();
+ virStateInitialize(server->privileged);
return server;
}
@@ -915,7 +914,7 @@ static struct qemud_server *qemudNetwork
}
#ifdef HAVE_AVAHI
- if (getuid() == 0 && mdns_adv) {
+ if (server->privileged && mdns_adv) {
struct libvirtd_mdns_group *group;
int port = 0;
@@ -2507,9 +2506,9 @@ remoteReadConfigFile (struct qemud_serve
#if HAVE_POLKIT
/* Change the default back to no auth for non-root */
- if (getuid() != 0 && auth_unix_rw == REMOTE_AUTH_POLKIT)
+ if (!server->privileged && auth_unix_rw == REMOTE_AUTH_POLKIT)
auth_unix_rw = REMOTE_AUTH_NONE;
- if (getuid() != 0 && auth_unix_ro == REMOTE_AUTH_POLKIT)
+ if (!server->privileged && auth_unix_ro == REMOTE_AUTH_POLKIT)
auth_unix_ro = REMOTE_AUTH_NONE;
#endif
@@ -2546,7 +2545,7 @@ remoteReadConfigFile (struct qemud_serve
GET_CONF_STR (conf, filename, unix_sock_group);
if (unix_sock_group) {
- if (getuid() != 0) {
+ if (!server->privileged) {
VIR_WARN0(_("Cannot set group when not running as root"));
} else {
int ret;
@@ -2871,7 +2870,7 @@ int main(int argc, char **argv) {
sigaction(SIGPIPE, &sig_action, NULL);
/* Ensure the rundir exists (on tmpfs on some systems) */
- if (geteuid () == 0) {
+ if (getuid() == 0) {
const char *rundir = LOCAL_STATE_DIR "/run/libvirt";
if (mkdir (rundir, 0755)) {
@@ -2882,6 +2881,12 @@ int main(int argc, char **argv) {
}
}
+ /* Beyond this point, nothing should rely on using
+ * getuid/geteuid() == 0, for privilege level checks.
+ * It must all use the flag 'server->privileged'
+ * which is also passed into all libvirt stateful
+ * drivers
+ */
if (qemudSetupPrivs() < 0)
goto error2;
@@ -2895,7 +2900,7 @@ int main(int argc, char **argv) {
goto error2;
/* Change the group ownership of /var/run/libvirt to unix_sock_gid */
- if (unix_sock_dir && geteuid() == 0) {
+ if (unix_sock_dir && server->privileged) {
if (chown(unix_sock_dir, -1, unix_sock_gid) < 0)
VIR_ERROR(_("Failed to change group ownership of %s"),
unix_sock_dir);
diff -r 5e3b5d1f91c2 qemud/qemud.h
--- a/qemud/qemud.h Thu May 21 16:21:20 2009 +0100
+++ b/qemud/qemud.h Thu May 21 16:27:16 2009 +0100
@@ -172,6 +172,8 @@ struct qemud_server {
virMutex lock;
virCond job;
+ int privileged;
+
int nworkers;
int nactiveworkers;
struct qemud_worker *workers;
diff -r 5e3b5d1f91c2 src/driver.h
--- a/src/driver.h Thu May 21 16:21:20 2009 +0100
+++ b/src/driver.h Thu May 21 16:27:16 2009 +0100
@@ -717,7 +717,7 @@ struct _virStorageDriver {
};
#ifdef WITH_LIBVIRTD
-typedef int (*virDrvStateInitialize) (void);
+typedef int (*virDrvStateInitialize) (int privileged);
typedef int (*virDrvStateCleanup) (void);
typedef int (*virDrvStateReload) (void);
typedef int (*virDrvStateActive) (void);
diff -r 5e3b5d1f91c2 src/libvirt.c
--- a/src/libvirt.c Thu May 21 16:21:20 2009 +0100
+++ b/src/libvirt.c Thu May 21 16:27:16 2009 +0100
@@ -765,7 +765,7 @@ virRegisterStateDriver(virStateDriverPtr
*
* Return 0 if all succeed, -1 upon any failure.
*/
-int virStateInitialize(void) {
+int virStateInitialize(int privileged) {
int i, ret = 0;
if (virInitialize() < 0)
@@ -773,7 +773,7 @@ int virStateInitialize(void) {
for (i = 0 ; i < virStateDriverTabCount ; i++) {
if (virStateDriverTab[i]->initialize &&
- virStateDriverTab[i]->initialize() < 0)
+ virStateDriverTab[i]->initialize(privileged) < 0)
ret = -1;
}
return ret;
diff -r 5e3b5d1f91c2 src/libvirt_internal.h
--- a/src/libvirt_internal.h Thu May 21 16:21:20 2009 +0100
+++ b/src/libvirt_internal.h Thu May 21 16:27:16 2009 +0100
@@ -26,7 +26,7 @@
#ifdef WITH_LIBVIRTD
-int virStateInitialize(void);
+int virStateInitialize(int privileged);
int virStateCleanup(void);
int virStateReload(void);
int virStateActive(void);
diff -r 5e3b5d1f91c2 src/lxc_driver.c
--- a/src/lxc_driver.c Thu May 21 16:21:20 2009 +0100
+++ b/src/lxc_driver.c Thu May 21 16:27:16 2009 +0100
@@ -51,7 +51,7 @@
#define VIR_FROM_THIS VIR_FROM_LXC
-static int lxcStartup(void);
+static int lxcStartup(int privileged);
static int lxcShutdown(void);
static lxc_driver_t *lxc_driver = NULL;
@@ -67,15 +67,6 @@ static void lxcDriverUnlock(lxc_driver_t
}
-static int lxcProbe(void)
-{
- if (getuid() != 0 ||
- lxcContainerAvailable(0) < 0)
- return 0;
-
- return 1;
-}
-
static virDrvOpenStatus lxcOpen(virConnectPtr conn,
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
int flags ATTRIBUTE_UNUSED)
@@ -86,9 +77,6 @@ static virDrvOpenStatus lxcOpen(virConne
if (lxc_driver == NULL)
return VIR_DRV_OPEN_DECLINED;
- if (!lxcProbe())
- return VIR_DRV_OPEN_DECLINED;
-
conn->uri = xmlParseURI("lxc:///");
if (!conn->uri) {
virReportOOMError(conn);
@@ -115,12 +103,6 @@ static virDrvOpenStatus lxcOpen(virConne
_("lxc state driver is not active"));
return VIR_DRV_OPEN_ERROR;
}
-
- if (!lxcProbe()) {
- lxcError(conn, NULL, VIR_ERR_INTERNAL_ERROR,
- _("kernel does not support LXC feature"));
- return VIR_DRV_OPEN_ERROR;
- }
}
conn->privateData = lxc_driver;
@@ -1149,9 +1131,8 @@ static int lxcCheckNetNsSupport(void)
return 1;
}
-static int lxcStartup(void)
+static int lxcStartup(int privileged)
{
- uid_t uid = getuid();
unsigned int i;
char *ld;
@@ -1164,7 +1145,7 @@ static int lxcStartup(void)
return -1;
/* Check that the user is root */
- if (0 != uid) {
+ if (!privileged) {
return -1;
}
diff -r 5e3b5d1f91c2 src/network_driver.c
--- a/src/network_driver.c Thu May 21 16:21:20 2009 +0100
+++ b/src/network_driver.c Thu May 21 16:27:16 2009 +0100
@@ -182,7 +182,7 @@ networkAutostartConfigs(struct network_d
* Initialization function for the QEmu daemon
*/
static int
-networkStartup(void) {
+networkStartup(int privileged) {
uid_t uid = geteuid();
char *base = NULL;
int err;
@@ -196,7 +196,7 @@ networkStartup(void) {
}
networkDriverLock(driverState);
- if (!uid) {
+ if (privileged) {
if (virAsprintf(&driverState->logDir,
"%s/log/libvirt/qemu", LOCAL_STATE_DIR) == -1)
goto out_of_memory;
diff -r 5e3b5d1f91c2 src/node_device_devkit.c
--- a/src/node_device_devkit.c Thu May 21 16:21:20 2009 +0100
+++ b/src/node_device_devkit.c Thu May 21 16:27:16 2009 +0100
@@ -284,7 +284,7 @@ static void dev_create(void *_dkdev, voi
}
-static int devkitDeviceMonitorStartup(void)
+static int devkitDeviceMonitorStartup(int privileged ATTRIBUTE_UNUSED)
{
size_t caps_tbl_len = sizeof(caps_tbl) / sizeof(caps_tbl[0]);
DevkitClient *devkit_client = NULL;
diff -r 5e3b5d1f91c2 src/node_device_hal.c
--- a/src/node_device_hal.c Thu May 21 16:21:20 2009 +0100
+++ b/src/node_device_hal.c Thu May 21 16:27:16 2009 +0100
@@ -661,7 +661,7 @@ static void toggle_dbus_watch(DBusWatch
}
-static int halDeviceMonitorStartup(void)
+static int halDeviceMonitorStartup(int privileged ATTRIBUTE_UNUSED)
{
LibHalContext *hal_ctx = NULL;
DBusConnection *dbus_conn = NULL;
diff -r 5e3b5d1f91c2 src/qemu_conf.h
--- a/src/qemu_conf.h Thu May 21 16:21:20 2009 +0100
+++ b/src/qemu_conf.h Thu May 21 16:27:16 2009 +0100
@@ -62,6 +62,8 @@ enum qemud_cmd_flags {
struct qemud_driver {
virMutex lock;
+ int privileged;
+
unsigned int qemuVersion;
int nextvmid;
diff -r 5e3b5d1f91c2 src/qemu_driver.c
--- a/src/qemu_driver.c Thu May 21 16:21:20 2009 +0100
+++ b/src/qemu_driver.c Thu May 21 16:27:16 2009 +0100
@@ -130,24 +130,26 @@ static struct qemud_driver *qemu_driver
static int
-qemudLogFD(virConnectPtr conn, const char* logDir, const char* name)
+qemudLogFD(virConnectPtr conn, struct qemud_driver *driver, const char* name)
{
char logfile[PATH_MAX];
mode_t logmode;
- uid_t uid = geteuid();
int ret, fd = -1;
- if ((ret = snprintf(logfile, sizeof(logfile), "%s/%s.log", logDir, name))
+ if ((ret = snprintf(logfile, sizeof(logfile), "%s/%s.log",
+ driver->logDir, name))
< 0 || ret >= sizeof(logfile)) {
virReportOOMError(conn);
return -1;
}
logmode = O_CREAT | O_WRONLY;
- if (uid != 0)
+ /* Only logrotate files in /var/log, so only append if running privileged */
+ if (driver->privileged)
+ logmode |= O_APPEND;
+ else
logmode |= O_TRUNC;
- else
- logmode |= O_APPEND;
+
if ((fd = open(logfile, logmode, S_IRUSR | S_IWUSR)) < 0) {
virReportSystemError(conn, errno,
_("failed to create logfile %s"),
@@ -210,9 +212,9 @@ qemudAutostartConfigs(struct qemud_drive
* to lookup the bridge associated with a virtual
* network
*/
- virConnectPtr conn = virConnectOpen(getuid() ?
- "qemu:///session" :
- "qemu:///system");
+ virConnectPtr conn = virConnectOpen(driver->privileged ?
+ "qemu:///system" :
+ "qemu:///session");
/* Ignoring NULL conn which is mostly harmless here */
qemuDriverLock(driver);
@@ -333,7 +335,7 @@ qemudReconnectVMs(struct qemud_driver *d
goto next_error;
}
- if ((vm->logfile = qemudLogFD(NULL, driver->logDir, vm->def->name)) < 0)
+ if ((vm->logfile = qemudLogFD(NULL, driver, vm->def->name)) < 0)
goto next_error;
if (vm->def->id >= driver->nextvmid)
@@ -420,8 +422,7 @@ qemudSecurityInit(struct qemud_driver *q
* Initialization function for the QEmu daemon
*/
static int
-qemudStartup(void) {
- uid_t uid = geteuid();
+qemudStartup(int privileged) {
char *base = NULL;
char driverConf[PATH_MAX];
@@ -434,6 +435,7 @@ qemudStartup(void) {
return -1;
}
qemuDriverLock(qemu_driver);
+ qemu_driver->privileged = privileged;
/* Don't have a dom0 so start from 1 */
qemu_driver->nextvmid = 1;
@@ -448,7 +450,7 @@ qemudStartup(void) {
virEventAddTimeout(-1, qemuDomainEventFlush, qemu_driver, NULL)) < 0)
goto error;
- if (!uid) {
+ if (privileged) {
if (virAsprintf(&qemu_driver->logDir,
"%s/log/libvirt/qemu", LOCAL_STATE_DIR) == -1)
goto out_of_memory;
@@ -460,6 +462,7 @@ qemudStartup(void) {
"%s/run/libvirt/qemu/", LOCAL_STATE_DIR) == -1)
goto out_of_memory;
} else {
+ uid_t uid = geteuid();
char *userdir = virGetUserDirectory(NULL, uid);
if (!userdir)
goto error;
@@ -1372,7 +1375,7 @@ static int qemudStartVMDaemon(virConnect
goto cleanup;
}
- if((vm->logfile = qemudLogFD(conn, driver->logDir, vm->def->name)) < 0)
+ if ((vm->logfile = qemudLogFD(conn, driver, vm->def->name)) < 0)
goto cleanup;
emulator = vm->def->emulator;
@@ -1773,8 +1776,6 @@ static int qemudProbe(void)
static virDrvOpenStatus qemudOpen(virConnectPtr conn,
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
int flags ATTRIBUTE_UNUSED) {
- uid_t uid = getuid();
-
if (conn->uri == NULL) {
if (qemu_driver == NULL)
return VIR_DRV_OPEN_DECLINED;
@@ -1782,7 +1783,7 @@ static virDrvOpenStatus qemudOpen(virCon
if (!qemudProbe())
return VIR_DRV_OPEN_DECLINED;
- conn->uri = xmlParseURI(uid == 0 ?
+ conn->uri = xmlParseURI(qemu_driver->privileged ?
"qemu:///system" :
"qemu:///session");
if (!conn->uri) {
@@ -1805,7 +1806,7 @@ static virDrvOpenStatus qemudOpen(virCon
return VIR_DRV_OPEN_ERROR;
}
- if (!uid) {
+ if (qemu_driver->privileged) {
if (STRNEQ (conn->uri->path, "/system") &&
STRNEQ (conn->uri->path, "/session")) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
diff -r 5e3b5d1f91c2 src/remote_internal.c
--- a/src/remote_internal.c Thu May 21 16:21:20 2009 +0100
+++ b/src/remote_internal.c Thu May 21 16:27:16 2009 +0100
@@ -235,7 +235,7 @@ static gnutls_session_t negotiate_gnutls
#ifdef WITH_LIBVIRTD
static int
-remoteStartup(void)
+remoteStartup(int privileged ATTRIBUTE_UNUSED)
{
/* Mark that we're inside the daemon so we can avoid
* re-entering ourselves
diff -r 5e3b5d1f91c2 src/storage_driver.c
--- a/src/storage_driver.c Thu May 21 16:21:20 2009 +0100
+++ b/src/storage_driver.c Thu May 21 16:27:16 2009 +0100
@@ -106,8 +106,7 @@ storageDriverAutostart(virStorageDriverS
* Initialization function for the QEmu daemon
*/
static int
-storageDriverStartup(void) {
- uid_t uid = geteuid();
+storageDriverStartup(int privileged) {
char *base = NULL;
char driverConf[PATH_MAX];
@@ -120,10 +119,11 @@ storageDriverStartup(void) {
}
storageDriverLock(driverState);
- if (!uid) {
+ if (privileged) {
if ((base = strdup (SYSCONF_DIR "/libvirt")) == NULL)
goto out_of_memory;
} else {
+ uid_t uid = geteuid();
char *userdir = virGetUserDirectory(NULL, uid);
if (!userdir)
diff -r 5e3b5d1f91c2 src/uml_conf.h
--- a/src/uml_conf.h Thu May 21 16:21:20 2009 +0100
+++ b/src/uml_conf.h Thu May 21 16:27:16 2009 +0100
@@ -42,6 +42,8 @@
struct uml_driver {
virMutex lock;
+ int privileged;
+
unsigned int umlVersion;
int nextvmid;
diff -r 5e3b5d1f91c2 src/uml_driver.c
--- a/src/uml_driver.c Thu May 21 16:21:20 2009 +0100
+++ b/src/uml_driver.c Thu May 21 16:27:16 2009 +0100
@@ -131,9 +131,9 @@ umlAutostartConfigs(struct uml_driver *d
* to lookup the bridge associated with a virtual
* network
*/
- virConnectPtr conn = virConnectOpen(getuid() ?
- "uml:///session" :
- "uml:///system");
+ virConnectPtr conn = virConnectOpen(driver->privileged ?
+ "uml:///system" :
+ "uml:///session");
/* Ignoring NULL conn which is mostly harmless here */
for (i = 0 ; i < driver->domains.count ; i++) {
@@ -308,7 +308,7 @@ cleanup:
* Initialization function for the Uml daemon
*/
static int
-umlStartup(void) {
+umlStartup(int privileged) {
uid_t uid = geteuid();
char *base = NULL;
char driverConf[PATH_MAX];
@@ -317,6 +317,8 @@ umlStartup(void) {
if (VIR_ALLOC(uml_driver) < 0)
return -1;
+ uml_driver->privileged = privileged;
+
if (virMutexInit(¨_driver->lock) < 0) {
VIR_FREE(uml_driver);
return -1;
@@ -331,7 +333,7 @@ umlStartup(void) {
if (!userdir)
goto error;
- if (!uid) {
+ if (privileged) {
if (virAsprintf(¨_driver->logDir,
"%s/log/libvirt/uml", LOCAL_STATE_DIR) == -1)
goto out_of_memory;
@@ -887,13 +889,11 @@ static void umlShutdownVMDaemon(virConne
static virDrvOpenStatus umlOpen(virConnectPtr conn,
virConnectAuthPtr auth ATTRIBUTE_UNUSED,
int flags ATTRIBUTE_UNUSED) {
- uid_t uid = getuid();
-
if (conn->uri == NULL) {
if (uml_driver == NULL)
return VIR_DRV_OPEN_DECLINED;
- conn->uri = xmlParseURI(uid == 0 ?
+ conn->uri = xmlParseURI(uml_driver->privileged ?
"uml:///system" :
"uml:///session");
if (!conn->uri) {
@@ -915,7 +915,7 @@ static virDrvOpenStatus umlOpen(virConne
return VIR_DRV_OPEN_ERROR;
}
- if (uid == 0) {
+ if (uml_driver->privileged) {
if (STRNEQ (conn->uri->path, "/system") &&
STRNEQ (conn->uri->path, "/session")) {
umlReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
diff -r 5e3b5d1f91c2 src/xen_internal.c
--- a/src/xen_internal.c Thu May 21 16:21:20 2009 +0100
+++ b/src/xen_internal.c Thu May 21 16:27:16 2009 +0100
@@ -3434,6 +3434,6 @@ xenHavePrivilege()
#ifdef __sun
return priv_ineffect (PRIV_XVM_CONTROL);
#else
- return getuid () == 0;
+ return access(XEN_HYPERVISOR_SOCKET, R_OK) == 0;
#endif
}
diff -r 5e3b5d1f91c2 src/xen_unified.c
--- a/src/xen_unified.c Thu May 21 16:21:20 2009 +0100
+++ b/src/xen_unified.c Thu May 21 16:27:16 2009 +0100
@@ -175,7 +175,7 @@ done:
#ifdef WITH_LIBVIRTD
static int
-xenInitialize (void)
+xenInitialize (int privileged ATTRIBUTE_UNUSED)
{
inside_daemon = 1;
return 0;
--
|: 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 :|
2
2
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
2
4
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 :|
3
3
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
3
12