[libvirt] [PATCH 0/1] Fix bogus WWNs
by David Allan
When HBA kernel modules are loaded while libvirt is running, libvirt
will often read bogus WWNs from sysfs as at least some modules trigger
the HAL event notifying libvirt of adapters' existence before the
sysfs info is correct. The following patch causes libvirt to reread
the WWNs whenever dumpxml is called so the capability information
about the WWNs will be up to date.
I pulled the logic to read the WWNs into two separate functions, and
the patch is slightly more invasive as a result. The resulting code
is smaller and cleaner for it, though, so I think this is the right
way to go. (The diff is also very ugly; it should make sense once
applied.)
Dave
15 years, 5 months
[libvirt] virStorageVolCreateXMLFrom
by Kenneth Nagin
I'd like to get a better understanding of the virStorageVolCreateXMLFrom
api Its name and signature imply that it is a cloning operation that copies
a volume from one location to another. Is this correct?
Assuming that the answer is yes I have few other questions:
Does it support remote copy of non-shared storage, e.g. from a http server?
Is there any thought about adding digest validation check, e.g. with a md5
digest?
Is copy-on-write cloning supported in this command?
Kenneth Nagin
15 years, 5 months
[libvirt] [PATCH] For comment/critique only - netcf backend for virInterface*.
by Laine Stump
This is the backend for the interface driver (virInterface*()) that
uses netcf. There are a few issues with it:
1) It doesn't yet implement the backend for
virConnectListDefinedInterfaces() and
virConnectNumOfDefinedInterfaces() (although it does use my patched
netcf API to list only active interfaces for
virConnectListInterfaces()). (That patch isn't committed to netcf
yet, btw; it's functional, but a bit rough and hackish)
2) interfaceLookupByMACString() still uses the old arg convention for
ncf_lookup_by_mac_string(), which returned a single interface. That
function has been changed to potentially return multiple
interfaces. To fully support that, we would need to change the
libvirt API. What should we do here?
3) The XML in interfaceDefineXML() isn't validated, although the spot to
do it is clearly marked.
4) There's no comment in the place where we could, in the future, transform
the XML returned to interfaceGetXMLDesc() by netcf. Currently the two
use the same RNG. Since it would be a null transform, and that will only
change under our control, that isn't an *immediate* problem, but shouldn't
be forgotten.
Parts that I'm unsure of:
1) changes to the Makefile, particularly surrounding "DRIVER_MODULES".
2) Is it registered in the proper places?
3) Could it (should it?) be added to other hypervisor drivers?
(Currently I only put it in qemud.c)
---
qemud/Makefile.am | 4 +
qemud/qemud.c | 6 +
src/Makefile.am | 16 ++-
src/interface_driver.c | 381 ++++++++++++++++++++++++++++++++++++++++++++++++
src/interface_driver.h | 34 +++++
5 files changed, 440 insertions(+), 1 deletions(-)
create mode 100644 src/interface_driver.c
create mode 100644 src/interface_driver.h
diff --git a/qemud/Makefile.am b/qemud/Makefile.am
index 403846a..9f982ba 100644
--- a/qemud/Makefile.am
+++ b/qemud/Makefile.am
@@ -134,6 +134,10 @@ if WITH_NETWORK
libvirtd_LDADD += ../src/libvirt_driver_network.la
endif
+if WITH_NETCF
+ libvirtd_LDADD += ../src/libvirt_driver_interface.la
+endif
+
if WITH_NODE_DEVICES
libvirtd_LDADD += ../src/libvirt_driver_nodedev.la
endif
diff --git a/qemud/qemud.c b/qemud/qemud.c
index b5e3665..9326ce9 100644
--- a/qemud/qemud.c
+++ b/qemud/qemud.c
@@ -81,6 +81,9 @@
#ifdef WITH_NETWORK
#include "network_driver.h"
#endif
+#ifdef WITH_NETCF
+#include "interface_driver.h"
+#endif
#ifdef WITH_STORAGE_DIR
#include "storage_driver.h"
#endif
@@ -822,6 +825,9 @@ static struct qemud_server *qemudInitialize(int sigread) {
#ifdef WITH_NETWORK
networkRegister();
#endif
+#ifdef WITH_NETCF
+ interfaceRegister();
+#endif
#ifdef WITH_STORAGE_DIR
storageRegister();
#endif
diff --git a/src/Makefile.am b/src/Makefile.am
index f65e7ad..f5bf1b8 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -154,6 +154,9 @@ ONE_DRIVER_SOURCES = \
NETWORK_DRIVER_SOURCES = \
network_driver.h network_driver.c
+INTERFACE_DRIVER_SOURCES = \
+ interface_driver.h interface_driver.c
+
# Storage backend specific impls
STORAGE_DRIVER_SOURCES = \
storage_driver.h storage_driver.c \
@@ -381,8 +384,18 @@ libvirt_driver_network_la_SOURCES = $(NETWORK_DRIVER_SOURCES)
endif
if WITH_NETCF
-libvirt_driver_interface_la_CFLAGS = $(NETCF_CFLAGS)
libvirt_driver_interface_la_LDFLAGS = $(NETCF_LIBS)
+libvirt_driver_interface_la_CFLAGS = $(NETCF_CFLAGS)
+if WITH_DRIVER_MODULES
+mod_LTLIBRARIES += libvirt_driver_interface.la
+else
+noinst_LTLIBRARIES += libvirt_driver_interface.la
+libvirt_la_LIBADD += libvirt_driver_interface.la
+endif
+if WITH_DRIVER_MODULES
+libvirt_driver_interface_la_LDFLAGS += -module -avoid-version
+endif
+libvirt_driver_interface_la_SOURCES = $(INTERFACE_DRIVER_SOURCES)
endif
# Needed to keep automake quiet about conditionals
@@ -467,6 +480,7 @@ EXTRA_DIST += \
$(OPENVZ_DRIVER_SOURCES) \
$(VBOX_DRIVER_SOURCES) \
$(NETWORK_DRIVER_SOURCES) \
+ $(INTERFACE_DRIVER_SOURCES) \
$(STORAGE_DRIVER_SOURCES) \
$(STORAGE_DRIVER_FS_SOURCES) \
$(STORAGE_DRIVER_LVM_SOURCES) \
diff --git a/src/interface_driver.c b/src/interface_driver.c
new file mode 100644
index 0000000..b6cf510
--- /dev/null
+++ b/src/interface_driver.c
@@ -0,0 +1,381 @@
+/*
+ * interface_driver.c: backend driver methods to handle physical
+ * interface configuration using the netcf library.
+ *
+ * Copyright (C) 2006-2009 Red Hat, Inc.
+ * Copyright (C) 2006 Daniel P. Berrange
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Daniel P. Berrange <berrange(a)redhat.com>
+ */
+
+#include <config.h>
+
+#include <sys/types.h>
+#include <sys/poll.h>
+#include <dirent.h>
+#include <limits.h>
+#include <string.h>
+#include <stdio.h>
+#include <strings.h>
+#include <stdarg.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+#include <sys/utsname.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <paths.h>
+#include <pwd.h>
+#include <stdio.h>
+#include <sys/wait.h>
+#include <sys/ioctl.h>
+#include <netcf.h>
+
+#include "virterror_internal.h"
+#include "datatypes.h"
+#include "interface_driver.h"
+#include "driver.h"
+#include "event.h"
+#include "buf.h"
+#include "util.h"
+#include "memory.h"
+#include "logging.h"
+
+#define VIR_FROM_THIS VIR_FROM_INTERFACE
+
+#define interfaceReportError(conn, dom, net, code, fmt...) \
+ virReportErrorHelper(conn, VIR_FROM_THIS, code, __FILE__, \
+ __FUNCTION__, __LINE__, fmt)
+
+/* Main driver state */
+struct interface_driver
+{
+ virMutex lock;
+ struct netcf *netcf;
+};
+
+
+static void interfaceDriverLock(struct interface_driver *driver)
+{
+ virMutexLock(&driver->lock);
+}
+
+static void interfaceDriverUnlock(struct interface_driver *driver)
+{
+ virMutexUnlock(&driver->lock);
+}
+
+
+static struct interface_driver *driverState = NULL;
+
+static virDrvOpenStatus interfaceOpenInterface(virConnectPtr conn,
+ virConnectAuthPtr auth ATTRIBUTE_UNUSED,
+ int flags ATTRIBUTE_UNUSED)
+{
+ if (VIR_ALLOC(driverState) < 0)
+ {
+ virReportOOMError(conn);
+ goto alloc_error;
+ }
+
+ /* initialize non-0 stuff in driverState */
+ if (virMutexInit(&driverState->lock) < 0)
+ {
+ /* what error to report? */
+ goto mutex_error;
+ }
+
+ /* open netcf */
+ if (ncf_init(&driverState->netcf, NULL) != 0)
+ {
+ /* what error to report? */
+ goto netcf_error;
+ }
+
+ conn->interfacePrivateData = driverState;
+ return 0;
+
+netcf_error:
+ if (driverState->netcf)
+ {
+ ncf_close(driverState->netcf);
+ }
+ virMutexDestroy (&driverState->lock);
+mutex_error:
+ VIR_FREE(driverState);
+alloc_error:
+ return -1;
+}
+
+static int interfaceCloseInterface(virConnectPtr conn)
+{
+
+ if (conn->interfacePrivateData != NULL)
+ {
+ struct interface_driver *driver
+ = (struct interface_driver *)conn->interfacePrivateData;
+
+ /* close netcf instance */
+ ncf_close(driver->netcf);
+ /* destroy lock */
+ virMutexDestroy(&driver->lock);
+ /* free driverState */
+ VIR_FREE(driver);
+ }
+ conn->interfacePrivateData = NULL;
+ return 0;
+}
+
+static int interfaceNumInterfaces(virConnectPtr conn)
+{
+ int count;
+ struct interface_driver *driver = conn->interfacePrivateData;
+
+ interfaceDriverLock(driver);
+ count = ncf_num_of_interfaces(driver->netcf, NETCF_FLAG_ACTIVE);
+ interfaceDriverUnlock(driver);
+ return count;
+}
+
+static int interfaceListInterfaces(virConnectPtr conn, char **const names, int nnames)
+{
+ struct interface_driver *driver = conn->interfacePrivateData;
+ int count;
+
+ interfaceDriverLock(driver);
+
+ count = ncf_list_interfaces(driver->netcf, nnames, names, NETCF_FLAG_ACTIVE);
+ /* netcf cleans up in the case of errors */
+ interfaceDriverUnlock(driver);
+
+ return count;
+
+}
+
+static virInterfacePtr interfaceLookupByName(virConnectPtr conn,
+ const char *name)
+{
+ struct interface_driver *driver = conn->interfacePrivateData;
+ struct netcf_if *iface;
+ virInterfacePtr ret = NULL;
+
+ interfaceDriverLock(driver);
+ iface = ncf_lookup_by_name(driver->netcf, name);
+
+ if (!iface) {
+ interfaceReportError(conn, NULL, NULL, VIR_ERR_NO_INTERFACE,
+ "%s", _("no interface with matching name"));
+ goto cleanup;
+ }
+
+ ret = virGetInterface(conn, ncf_if_name(iface), ncf_if_mac_string(iface));
+
+cleanup:
+ ncf_if_free(iface);
+ interfaceDriverUnlock(driver);
+ return ret;
+}
+
+static virInterfacePtr interfaceLookupByMACString(virConnectPtr conn,
+ const char *macstr)
+{
+ struct interface_driver *driver = conn->interfacePrivateData;
+ struct netcf_if *iface;
+ virInterfacePtr ret = NULL;
+
+ interfaceDriverLock(driver);
+ iface = ncf_lookup_by_mac_string(driver->netcf, macstr);
+
+ if (!iface) {
+ interfaceReportError(conn, NULL, NULL, VIR_ERR_NO_INTERFACE,
+ "%s", _("no interface with matching MAC address"));
+ goto cleanup;
+ }
+
+ ret = virGetInterface(conn, ncf_if_name(iface), ncf_if_mac_string(iface));
+
+cleanup:
+ ncf_if_free(iface);
+ interfaceDriverUnlock(driver);
+ return ret;
+}
+
+static char *interfaceGetXMLDesc(virInterfacePtr ifinfo,
+ unsigned int flags ATTRIBUTE_UNUSED)
+{
+ struct interface_driver *driver = ifinfo->conn->interfacePrivateData;
+ struct netcf_if *iface = NULL;
+ char *ret = NULL;
+
+ interfaceDriverLock(driver);
+ iface = ncf_lookup_by_name(driver->netcf, ifinfo->name);
+
+ if (!iface) {
+ /* May want to check by name here, but probably pointless */
+ interfaceReportError(ifinfo->conn, NULL, ifinfo, VIR_ERR_INVALID_INTERFACE,
+ "%s", _("no interface with matching MAC Address"));
+ goto cleanup;
+ }
+
+ ret = ncf_if_xml_desc(iface);
+ if (!ret) {
+ interfaceReportError(ifinfo->conn, NULL, ifinfo, VIR_ERR_INVALID_INTERFACE,
+ "%s", _("could not get interface XML description"));
+ goto cleanup;
+ }
+
+cleanup:
+ ncf_if_free(iface);
+ interfaceDriverUnlock(driver);
+ return ret;
+}
+
+static virInterfacePtr interfaceDefineXML(virConnectPtr conn,
+ const char *xml,
+ unsigned int flags ATTRIBUTE_UNUSED)
+{
+ struct interface_driver *driver = conn->interfacePrivateData;
+ struct netcf_if *iface = NULL;
+ virInterfacePtr ret = NULL;
+
+ interfaceDriverLock(driver);
+
+ /*
+ * This is where we will want to validate the XML, and possibly
+ * transform it before sending it on.
+ */
+
+ iface = ncf_define(driver->netcf, xml);
+ if (!iface) {
+ interfaceReportError(conn, NULL, NULL, VIR_ERR_INVALID_INTERFACE,
+ "%s", _("failed to define new interface from XML"));
+ goto cleanup;
+ }
+
+ ret = virGetInterface(conn, ncf_if_name(iface), ncf_if_mac_string(iface));
+
+cleanup:
+ ncf_if_free(iface);
+ interfaceDriverUnlock(driver);
+ return ret;
+}
+
+static int interfaceUndefine(virInterfacePtr ifinfo) {
+ struct interface_driver *driver = ifinfo->conn->interfacePrivateData;
+ struct netcf_if *iface = NULL;
+ int ret = -1;
+
+ interfaceDriverLock(driver);
+
+ iface = ncf_lookup_by_name(driver->netcf, ifinfo->name);
+ if (!iface) {
+ interfaceReportError(ifinfo->conn, NULL, ifinfo, VIR_ERR_INVALID_INTERFACE,
+ "%s", _("no interface with matching MAC address"));
+ goto cleanup;
+ }
+
+ ret = ncf_if_undefine(iface);
+ if (ret < 0) {
+ interfaceReportError(ifinfo->conn, NULL, ifinfo, VIR_ERR_INVALID_INTERFACE,
+ "%s", _("failed to undefine interface"));
+ goto cleanup;
+ }
+
+cleanup:
+ ncf_if_free(iface);
+ interfaceDriverUnlock(driver);
+ return ret;
+}
+
+static int interfaceCreate(virInterfacePtr ifinfo,
+ unsigned int flags ATTRIBUTE_UNUSED)
+{
+ struct interface_driver *driver = ifinfo->conn->interfacePrivateData;
+ struct netcf_if *iface = NULL;
+ int ret = -1;
+
+ interfaceDriverLock(driver);
+
+ iface = ncf_lookup_by_name(driver->netcf, ifinfo->name);
+ if (!iface) {
+ interfaceReportError(ifinfo->conn, NULL, ifincof, VIR_ERR_INVALID_INTERFACE,
+ "%s", _("no interface with matching MAC address"));
+ goto cleanup;
+ }
+
+ ret = ncf_if_up(iface);
+ if (ret < 0) {
+ interfaceReportError(ifinfo->conn, NULL, ifinfo, VIR_ERR_INVALID_INTERFACE,
+ "%s", _("failed to create (start) interface"));
+ goto cleanup;
+ }
+
+cleanup:
+ ncf_if_free(iface);
+ interfaceDriverUnlock(driver);
+ return ret;
+}
+
+static int interfaceDestroy(virInterfacePtr ifinfo,
+ unsigned int flags ATTRIBUTE_UNUSED)
+{
+ struct interface_driver *driver = ifinfo->conn->interfacePrivateData;
+ struct netcf_if *iface = NULL;
+ int ret = -1;
+
+ interfaceDriverLock(driver);
+
+ iface = ncf_lookup_by_name(driver->netcf, ifinfo->name);
+ if (!iface) {
+ interfaceReportError(ifinfo->conn, NULL, ifinfo, VIR_ERR_INVALID_INTERFACE,
+ "%s", _("no interface with matching MAC address"));
+ goto cleanup;
+ }
+
+ ret = ncf_if_down(iface);
+ if (ret < 0) {
+ interfaceReportError(ifinfo->conn, NULL, ifinfo, VIR_ERR_INVALID_INTERFACE,
+ "%s", _("failed to destroy (stop) interface"));
+ goto cleanup;
+ }
+
+cleanup:
+ ncf_if_free(iface);
+ interfaceDriverUnlock(driver);
+ return ret;
+}
+
+static virInterfaceDriver interfaceDriver = {
+ "Interface",
+ interfaceOpenInterface, /* open */
+ interfaceCloseInterface, /* close */
+ interfaceNumInterfaces, /* numOfInterfaces */
+ interfaceListInterfaces, /* listInterfaces */
+ interfaceLookupByName, /* interfaceLookupByName */
+ interfaceLookupByMACString, /* interfaceLookupByMACSTring */
+ interfaceGetXMLDesc, /* interfaceGetXMLDesc */
+ interfaceDefineXML, /* interfaceDefineXML */
+ interfaceUndefine, /* interfaceUndefine */
+ interfaceCreate, /* interfaceCreate */
+ interfaceDestroy, /* interfaceDestroy */
+};
+
+int interfaceRegister(void) {
+ virRegisterInterfaceDriver(&interfaceDriver);
+ return 0;
+}
diff --git a/src/interface_driver.h b/src/interface_driver.h
new file mode 100644
index 0000000..be00e0b
--- /dev/null
+++ b/src/interface_driver.h
@@ -0,0 +1,34 @@
+/*
+ * interface_driver.h: core driver methods for managing physical host interfaces
+ *
+ * Copyright (C) 2006, 2007 Red Hat, Inc.
+ * Copyright (C) 2006 Daniel P. Berrange
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this library; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ *
+ * Author: Daniel P. Berrange <berrange(a)redhat.com>
+ */
+
+
+#ifndef __VIR_INTERFACE__DRIVER_H
+#define __VIR_INTERFACE__DRIVER_H
+
+#include <config.h>
+
+#include "internal.h"
+
+int interfaceRegister(void);
+
+#endif /* __VIR_INTERFACE__DRIVER_H */
--
1.6.0.6
15 years, 5 months
[libvirt] VMware ESX driver status update
by Matthias Bolte
Hi,
I'm still working on the VMX config to domain XML mapping for
dump/create XML, but it's not complete yet. I got distracted by other
urgent, Uni related work that had to be done first.
So I won't be able to complete the dump/create XML implementation
until tomorrow (freeze for the 0.6.5 release) that was requested in
order to get the driver merged into the official repository. But well,
with the short release cycle of libvirt not much is lost :)
Some details on the VMX config to domain XML mapping:
I claimed before that I would need to read most information needed for
dump XML from the VMX config file. That's not true. Possibly all
information can be retrieved via VI API, but the information is
scattered in various places in the VI API object model. I'm currently
heading for reading this information from the VMX config file, because
all needed information is concentrated in this file. Also, if one
changes properties of a virtual machine via VI API and this properties
is reflected in the VMX config, the ESX host updates the VMX config,
so the information is kept in sync between the object model and the
config file.
I guess, that the VMX config files contains enough information to fill
all or at least most fields of a virDomainDef. So the first goal is to
fill a virDomainDef for dump XML.
The next goal would be a basic create XML. I claimed before that I
would need to write an VMX config file to the ESX host in order to
create a new virtual machine, but as I dig trough the VI API in more
detail, it seems that this claim maybe false. I'll just have to test
this, but haven't had time to do it yet.
One problem here is the essential guestOS field of the VMX config, see
http://sanbarrow.com/vmx/vmx-guestos.html . For a first try I would
set it to 'other' by default, because there is currently no field
available in the domain XML to map this information to. But to allow
the user to set this filed, I would want to extend to domain XML
definition in order to reuse existing code. So how would I do this?
Currently I'm just using the virDomainDef struct and the related parse
and format functions. One option would be to add a guest field to the
virDomainOSDef struct and extend the parse and format functions to
handle it. The parse and format functions take flags already, so a
flag could be added to indicate if the guest field should be handled
or not (just like the VMX extension for the virConfParser).
Regards,
Matthias
15 years, 5 months
[libvirt] [PATCH 0/3] Control Linux capabilities in libvirt
by Daniel P. Berrange
The libvirtd system instance runs privileged (as root), and likewise so do
VMs run from it. This is undesirable for obvious security reasons, even if
you do have SELinux available. Linux has a concept of capabilities which
are actually what gives 'root' its power. If you take away all capabilities
from a process running root, you significantly limit its power. eg if you
take away CAP_DAC_OVERRIDE, root can now only read files explicitly owned
by root, not any other users. There are about 30-something capabilities at
this time - see 'man 7 capabilities' for a full list and examples of what
each allows you todo
Historically it has needed alot of code to manage/modify capabilities, but
there is a new library for managing Linux capabilities recently released,
which makes their use significantly easier. This is known as libcap-ng
http://people.redhat.com/sgrubb/libcap-ng/
I anticipate a several step process
1. Drop all capabilities from spawned processes which don't need it
2. Reduce capabilities from the libvirtd daemon
3. Run VM processes as non-root, unprivileged users
4. Run the libvirtd daemon as as a non-root, semi-privileged user
This series of patches lays the very *basic* groundwork for controlling
Linux capabilities, doing options 1 and 2. Option '3' is what I'd really
like to get working, but it is more invasive, because it will need changes
to the QEMU driver so it will chown disks to the 'kvm' user before spawning
kvm (likewise for PCI devs, USB devs, etc).
Step 1 is a mild security benefit, adding step 3 is a significant step
forward. Step 2 doesn't have much tangible benefit, since our functionality
requires that we need CAP_DAC_OVERRIDE, CAP_SYS_ADMIN and CAP_NET_ADMIN.
Once you give a process those, its pretty much game over for security
benefits of removing other capabilities.
The 4th option *could* help security, but only if there are some changes
to the way distros deploy apps. In particular they'd need to make sure
binaries are installed with correct file capabilities, before we could
use it, otherwise we wouldnt' be able to get child processes we spawn to
keep capabilities they need. In addition, with step 4, we'd be asking
admins to trade off functionality against security. eg, we could only
drop CAP_DAC_OVERRIDE, if you turned off certain features. It is certainly
desirable for users who want to tightly lock down their system, but not
for a general purpose install.
Regards,
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] [PATCH] Fix reading storage pool defs on driver startup
by Cole Robinson
The recent storage refactoring I committed broke reading pool
definitions from disk on driver startup: the result was that none of
your pools would be defined. Frankly not sure how I managed to miss the
brokenness, sorry about that!
Also refactor the startup code to match the existing network and domain
conventions.
Thanks,
Cole
15 years, 5 months
[libvirt] Fix the no debug build
by Amy Griffis
The --enable-debug=no build breaks building the UML driver
because of __VA_ARGS__ in the virLogMessage macro. I fixed this
by converting umlLog() calls to use the standard logging macros
instead. The only problem I see with doing this is what Daniel
had mentioned a while back. Disabling debug actually turns off
the entire logging module instead of just the debug output. I can
work on fixing that part in another patch.
Signed-off-by: Amy Griffis <amy.griffis(a)hp.com>
diff --git a/src/uml_driver.c b/src/uml_driver.c
index 7949d4f..7aeb7bf 100644
--- a/src/uml_driver.c
+++ b/src/uml_driver.c
@@ -66,9 +66,6 @@
static int umlShutdown(void);
-#define umlLog(level, msg, ...) \
- virLogMessage(__FILE__, level, __func__, __LINE__, 0, msg, __VA_ARGS__)
-
static void umlDriverLock(struct uml_driver *driver)
{
virMutexLock(&driver->lock);
@@ -95,8 +92,7 @@ static int umlSetCloseExec(int fd) {
goto error;
return 0;
error:
- umlLog(VIR_LOG_ERROR,
- "%s", _("Failed to set close-on-exec file descriptor flag\n"));
+ VIR_ERROR0(_("Failed to set close-on-exec file descriptor flag"));
return -1;
}
@@ -136,7 +132,7 @@ umlAutostartConfigs(struct uml_driver *driver) {
!virDomainIsActive(driver->domains.objs[i]) &&
umlStartVMDaemon(conn, driver, driver->domains.objs[i]) < 0) {
virErrorPtr err = virGetLastError();
- umlLog(VIR_LOG_ERROR, _("Failed to autostart VM '%s': %s\n"),
+ VIR_ERROR(_("Failed to autostart VM '%s': %s"),
driver->domains.objs[i]->def->name, err->message);
}
}
@@ -368,13 +364,13 @@ umlStartup(int privileged) {
if ((uml_driver->inotifyFD = inotify_init()) < 0) {
- umlLog(VIR_LOG_ERROR, "%s", _("cannot initialize inotify"));
+ VIR_ERROR0(_("cannot initialize inotify"));
goto error;
}
if (virFileMakePath(uml_driver->monitorDir) < 0) {
char ebuf[1024];
- umlLog(VIR_LOG_ERROR, _("Failed to create monitor directory %s: %s"),
+ VIR_ERROR(_("Failed to create monitor directory %s: %s"),
uml_driver->monitorDir, virStrerror(errno, ebuf, sizeof ebuf));
goto error;
}
@@ -407,8 +403,7 @@ umlStartup(int privileged) {
return 0;
out_of_memory:
- umlLog (VIR_LOG_ERROR,
- "%s", _("umlStartup: out of memory\n"));
+ VIR_ERROR0(_("umlStartup: out of memory"));
error:
VIR_FREE(userdir);
@@ -825,25 +820,25 @@ static int umlStartVMDaemon(virConnectPtr conn,
tmp = progenv;
while (*tmp) {
if (safewrite(logfd, *tmp, strlen(*tmp)) < 0)
- umlLog(VIR_LOG_WARN, _("Unable to write envv to logfile: %s\n"),
+ VIR_WARN(_("Unable to write envv to logfile: %s"),
virStrerror(errno, ebuf, sizeof ebuf));
if (safewrite(logfd, " ", 1) < 0)
- umlLog(VIR_LOG_WARN, _("Unable to write envv to logfile: %s\n"),
+ VIR_WARN(_("Unable to write envv to logfile: %s"),
virStrerror(errno, ebuf, sizeof ebuf));
tmp++;
}
tmp = argv;
while (*tmp) {
if (safewrite(logfd, *tmp, strlen(*tmp)) < 0)
- umlLog(VIR_LOG_WARN, _("Unable to write argv to logfile: %s\n"),
+ VIR_WARN(_("Unable to write argv to logfile: %s"),
virStrerror(errno, ebuf, sizeof ebuf));
if (safewrite(logfd, " ", 1) < 0)
- umlLog(VIR_LOG_WARN, _("Unable to write argv to logfile: %s\n"),
+ VIR_WARN(_("Unable to write argv to logfile: %s"),
virStrerror(errno, ebuf, sizeof ebuf));
tmp++;
}
if (safewrite(logfd, "\n", 1) < 0)
- umlLog(VIR_LOG_WARN, _("Unable to write argv to logfile: %s\n"),
+ VIR_WARN(_("Unable to write argv to logfile: %s"),
virStrerror(errno, ebuf, sizeof ebuf));
vm->monitor = -1;
@@ -888,8 +883,7 @@ static void umlShutdownVMDaemon(virConnectPtr conn ATTRIBUTE_UNUSED,
vm->monitor = -1;
if ((ret = waitpid(vm->pid, NULL, 0)) != vm->pid) {
- umlLog(VIR_LOG_WARN,
- _("Got unexpected pid %d != %d\n"),
+ VIR_WARN(_("Got unexpected pid %d != %d"),
ret, vm->pid);
}
15 years, 5 months
[libvirt] Memory leak in node_device_conf.c
by Dave Allan
I found what I assume is a memory leak in the node device code while
working on a separate problem; patch attached.
Dave
diff --git a/src/node_device_conf.c b/src/node_device_conf.c
index 1fbf9dc..56a9bb5 100644
--- a/src/node_device_conf.c
+++ b/src/node_device_conf.c
@@ -1203,6 +1203,8 @@ void virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps)
VIR_FREE(data->net.address);
break;
case VIR_NODE_DEV_CAP_SCSI_HOST:
+ VIR_FREE(data->scsi_host.wwnn);
+ VIR_FREE(data->scsi_host.wwpn);
break;
case VIR_NODE_DEV_CAP_SCSI:
VIR_FREE(data->scsi.type);
15 years, 5 months