[libvirt] [PATCH qemu v2 0/6] -no-user-config option, move CPU models to /usr/share
by Eduardo Habkost
Changes v1 -> v2:
- Move qemu_read_default_config_files() prototype to qemu-config.h
- Make defconfig and userconfig variable bool
- Coding style change
Patches 1 to 4 just move some code around, patch 5 just adds the new option
without adding any new config file. Patch 6 finally creates a /usr/share/qemu
/cpus-x86_64.conf file, with the CPU models we currently have on Qemu.
Reference to previous discussion:
- http://marc.info/?l=qemu-devel&m=133278877315665
Eduardo Habkost (6):
move code to read default config files to a separate function (v2)
eliminate arch_config_name variable
move list of default config files to an array
vl.c: change 'defconfig' variable to bool
implement -no-user-config command-line option (v2)
move CPU definitions to /usr/share/qemu/cpus-x86_64.conf (v2)
Makefile | 12 +++-
arch_init.c | 32 ++++++++-
arch_init.h | 2 -
qemu-config.h | 4 +
qemu-options.hx | 16 ++++-
sysconfigs/target/cpus-x86_64.conf | 128 ++++++++++++++++++++++++++++++++++
sysconfigs/target/target-x86_64.conf | 128 ----------------------------------
vl.c | 18 ++---
8 files changed, 193 insertions(+), 147 deletions(-)
create mode 100644 sysconfigs/target/cpus-x86_64.conf
--
1.7.3.2
12 years, 6 months
[libvirt] [PATCH 1/2] virsh: make -h always give help
by Eric Blake
https://bugzilla.redhat.com/show_bug.cgi?id=817244 mentions that
unlike most other tools, where --help or --version prevent all
further parsing of all later options, virsh was strange in that
--version stopped parsing but --help tried to plow on to the end.
There was no rationale for this original implementation (since
2005!), so I think we can safely conform to common usage patterns.
* tools/virsh.c (main): Drop useless 'help' variable.
---
I think the intent might have been to someday allow:
virsh -h foo
to be short for
virsh help foo
but since that hasn't been implemented in 7 years, I think it
is smarter to be consistent with other tools instead.
tools/virsh.c | 15 ++-------------
1 files changed, 2 insertions(+), 13 deletions(-)
diff --git a/tools/virsh.c b/tools/virsh.c
index e177684..7159744 100644
--- a/tools/virsh.c
+++ b/tools/virsh.c
@@ -20179,7 +20179,6 @@ vshAllowedEscapeChar(char c)
static bool
vshParseArgv(vshControl *ctl, int argc, char **argv)
{
- bool help = false;
int arg, len;
struct option opt[] = {
{"debug", required_argument, NULL, 'd'},
@@ -20206,7 +20205,8 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
}
break;
case 'h':
- help = true;
+ vshUsage();
+ exit(EXIT_SUCCESS);
break;
case 'q':
ctl->quiet = true;
@@ -20251,17 +20251,6 @@ vshParseArgv(vshControl *ctl, int argc, char **argv)
}
}
- if (help) {
- if (optind < argc) {
- vshError(ctl, _("extra argument '%s'. See --help."), argv[optind]);
- exit(EXIT_FAILURE);
- }
-
- /* list all command */
- vshUsage();
- exit(EXIT_SUCCESS);
- }
-
if (argc > optind) {
/* parse command */
ctl->imode = false;
--
1.7.7.6
12 years, 6 months
[libvirt] [PATCH] util: fix crash when starting macvtap interfaces
by Laine Stump
This patch resolves https://bugzilla.redhat.com/show_bug.cgi?id=815270
The function virNetDevMacVLanVPortProfileRegisterCallback() takes an
arg "virtPortProfile", and was checking it for non-NULL before using
it. However, the prototype for
virNetDevMacVLanPortProfileRegisterCallback had marked that arg with
ATTRIBUTE_NONNULL(). Contrary to what one may think,
ATTRIBUTE_NONNULL() does not provide any guarantee that an arg marked
as such really is always non-null; the only effect to the code
generated by gcc, is that gcc *assumes* it is non-NULL; this results
in, for example, the check for a non-NULL value being optimized out.
(Unfortunately, this code removal only occurs when optimization is
enabled, and I am in the habit of doing local builds with optimization
off to ease debugging, so the bug didn't show up in my earlier local
testing).
In general, virPortProfile might always be NULL, so it shouldn't be
marked as ATTRIBUTE_NONNULL. One other function prototype made this
same error, so this patch fixes it as well.
---
src/util/virnetdevmacvlan.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/src/util/virnetdevmacvlan.h b/src/util/virnetdevmacvlan.h
index 2299f1d..07d54e2 100644
--- a/src/util/virnetdevmacvlan.h
+++ b/src/util/virnetdevmacvlan.h
@@ -82,7 +82,7 @@ int virNetDevMacVLanRestartWithVPortProfile(const char *cr_ifname,
virNetDevVPortProfilePtr virtPortProfile,
enum virNetDevVPortProfileOp vmOp)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
- ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5) ATTRIBUTE_RETURN_CHECK;
+ ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
int virNetDevMacVLanVPortProfileRegisterCallback(const char *ifname,
const unsigned char *macaddress ,
@@ -91,5 +91,5 @@ int virNetDevMacVLanVPortProfileRegisterCallback(const char *ifname,
virNetDevVPortProfilePtr virtPortProfile,
enum virNetDevVPortProfileOp vmOp)
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
-ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5) ATTRIBUTE_RETURN_CHECK;
+ATTRIBUTE_NONNULL(4) ATTRIBUTE_RETURN_CHECK;
#endif /* __UTIL_MACVTAP_H__ */
--
1.7.10
12 years, 6 months
[libvirt] [PATCH] maint: avoid false positives on unmarked diagnostics
by Eric Blake
Otherwise, a string such as _("Don't use \"" VAR "\".") would
complain about unmarked diagnostics.
* cfg.mk (sc_libvirt_unmarked_diagnostics): Handle \" in message.
---
I needed this patch to let me verify Stefan's DHCP Snooping series.
cfg.mk | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/cfg.mk b/cfg.mk
index fb4df2f..9935820 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -603,7 +603,7 @@ sc_libvirt_unmarked_diagnostics:
$(_sc_search_regexp)
@{ grep -nE '\<$(func_re) *\(.*;$$' $$($(VC_LIST_EXCEPT)); \
grep -A1 -nE '\<$(func_re) *\(.*,$$' $$($(VC_LIST_EXCEPT)); } \
- | sed 's/_("[^"][^"]*"//;s/[ ]"%s"//' \
+ | sed 's/_("\([^"]\|\\"\+\)*"//;s/[ ]"%s"//' \
| grep '[ ]"' && \
{ echo '$(ME): found unmarked diagnostic(s)' 1>&2; \
exit 1; } || :
--
1.7.7.6
12 years, 6 months
[libvirt] [PATCH V13 0/5] Add DHCP snooping support to nwfilter
by Stefan Berger
This series of patches adds DHCP snooping support to libvirt's
nwfilter subsystem.
DHCP snooping detects DHCP leases obtained by a VM and automatically
adjusts the network traffic filters to reflect the IP addresses
with which a VM may send its traffic, thus for example preventing
IP address spoofing.
Once leases on IP addresses expire or if a VM gives up on a
lease on an IP address, the filters are also adjusted.
All leases are persisted and automatically applied upon a VM's restart.
Leases are associated with the tuple of VM-UUID and interface MAC
address.
The following interface XML activates and uses the DHCP snooping:
<interface type='bridge'>
<source bridge='virbr0'/>
<filterref filter='clean-traffic'>
<parameter name='CTRL_IP_LEARNING' value='dhcp'/>
</filterref>
</interface>
Once an IP address has been detected on an interface, 'virsh dumpxml <vm>'
would show the IP address lease in the format <IP address>,<lease timeout
in seconds>:
<interface type='bridge'>
<source bridge='virbr0'/>
<filterref filter='clean-traffic'>
<parameter name='CTRL_IP_LEARNING' value='dhcp'/>
<parameter name='IP_LEASE' value='192.168.122.210,180'/>
</filterref>
</interface>
Regards,
David and Stefan
12 years, 6 months
[libvirt] [PATCH 0/3] usb devices with same vendor, productID hotplug support
by Guannan Ren
https://bugzilla.redhat.com/show_bug.cgi?id=815755
The set of patch tries to fix the issue when multiple usb devices with
same idVendor, idProduct are availible on host, the usb device with
lowest bus:device will be attached to guest if usb xml file is given like
this:
<hostdev mode='subsystem' type='usb' managed='yes'>
<source>
<vendor id='0x15e1'/>
<product id='0x2007'/>
</source>
</hostdev>
The reason is that the usb hotplug function searchs usb device in system files
to match vendor and product id, the file with lowest number is always found
first.
After fix, in this case, libvirt will report an error like:
At the same time, the usb part of domain initilization is also update in patch 2/3
# virsh attach-device rhel6u1 /tmp/usb.xml
error: Failed to attach device from /tmp/usb.xml
error: XML error: multiple USB deivces 15e1:2007, use <address> to specify one.
12 years, 6 months
[libvirt] [PATCH libvirt-glib] Add complete docs for the Libvirt GLib library
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Flesh out the section intros for each of the Libvirt GLib
library modules, providing using examples where needed, and
adding any missing function docs.
---
cfg.mk | 2 +-
configure.ac | 1 +
docs/libvirt-glib/Libvirt-glib-docs.xml | 7 +--
docs/libvirt-glib/Makefile.am | 2 +
docs/libvirt-glib/version.xml.in | 1 +
libvirt-glib/libvirt-glib-error.c | 56 +++++++++++++++++++----
libvirt-glib/libvirt-glib-event.c | 65 ++++++++++++++++++++++++++
libvirt-glib/libvirt-glib-main.c | 76 +++++++++++++++++++++++++++++++
8 files changed, 198 insertions(+), 12 deletions(-)
create mode 100644 docs/libvirt-glib/version.xml.in
diff --git a/cfg.mk b/cfg.mk
index ed46aee..099ffa3 100644
--- a/cfg.mk
+++ b/cfg.mk
@@ -124,7 +124,7 @@ sc_check_author_list:
test $$fail = 0
-exclude_file_name_regexp--sc_bindtextdomain = ^(libvirt-gconfig/tests|examples)/
+exclude_file_name_regexp--sc_bindtextdomain = ^(libvirt-gconfig/tests|examples)/|libvirt-glib/libvirt-glib-event.c|libvirt-glib/libvirt-glib-main.c
exclude_file_name_regexp--sc_preprocessor_indentation = ^*/*.[ch]
diff --git a/configure.ac b/configure.ac
index 31f82c9..4b974d4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -259,6 +259,7 @@ AC_OUTPUT(Makefile
vapi/Makefile
docs/Makefile
docs/libvirt-glib/Makefile
+ docs/libvirt-glib/version.xml
docs/libvirt-gobject/Makefile
docs/libvirt-gconfig/Makefile
libvirt-glib-1.0.pc
diff --git a/docs/libvirt-glib/Libvirt-glib-docs.xml b/docs/libvirt-glib/Libvirt-glib-docs.xml
index 5b6a873..f2f3572 100644
--- a/docs/libvirt-glib/Libvirt-glib-docs.xml
+++ b/docs/libvirt-glib/Libvirt-glib-docs.xml
@@ -3,21 +3,22 @@
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd"
[
<!ENTITY % local.common.attrib "xmlns:xi CDATA #FIXED 'http://www.w3.org/2003/XInclude'">
+ <!ENTITY version SYSTEM "version.xml">
]>
<book id="index">
<bookinfo>
- <title>Libvirt-glib Reference Manual</title>
+ <title>Libvirt GLib Reference Manual</title>
</bookinfo>
<chapter>
- <title>Libvirt-glib</title>
+ <title>API Reference</title>
<xi:include href="xml/libvirt-glib-main.xml"/>
<xi:include href="xml/libvirt-glib-error.xml"/>
<xi:include href="xml/libvirt-glib-event.xml"/>
</chapter>
<chapter id="object-tree">
<title>Object Hierarchy</title>
- <xi:include href="xml/tree_index.sgml"/>
+ <xi:include href="xml/tree_index.sgml"/>
</chapter>
<index id="api-index-full">
<title>API Index</title>
diff --git a/docs/libvirt-glib/Makefile.am b/docs/libvirt-glib/Makefile.am
index e45f4e2..186f8ff 100644
--- a/docs/libvirt-glib/Makefile.am
+++ b/docs/libvirt-glib/Makefile.am
@@ -39,3 +39,5 @@ GTKDOC_LIBS = \
$(top_builddir)/libvirt-glib/libvirt-glib-1.0.la
include $(top_srcdir)/gtk-doc.make
+
+EXTRA_DIST += version.xml.in
diff --git a/docs/libvirt-glib/version.xml.in b/docs/libvirt-glib/version.xml.in
new file mode 100644
index 0000000..d78bda9
--- /dev/null
+++ b/docs/libvirt-glib/version.xml.in
@@ -0,0 +1 @@
+@VERSION@
diff --git a/libvirt-glib/libvirt-glib-error.c b/libvirt-glib/libvirt-glib-error.c
index 4a44216..7356aed 100644
--- a/libvirt-glib/libvirt-glib-error.c
+++ b/libvirt-glib/libvirt-glib-error.c
@@ -29,11 +29,51 @@
#include "libvirt-glib/libvirt-glib.h"
/**
- * gvir_error_new: (skip)
+ * SECTION:libvirt-glib-error
+ * @short_description: Convert libvirt error reports to GLib error reports
+ * @title: Error reporting
+ * @stability: Stable
+ * @include: libvirt-glib/libvirt-glib.h
+ *
+ * The libvirt API uses the <code>virError</code> structure for reporting
+ * errors back to the application programmer. The libvirt API errors are
+ * provided in thread-local variables, while the GLib standard practice is
+ * to return errors via out parameters. This library provides a simple way
+ * to fill in <code>GError **</code> output parameters with the contents
+ * of the most recent libvirt error object in the current thread.
+ *
+ * The <code>gvir_error_new</code>, <code>gvir_error_new_literal</code> and
+ * <code>gvir_error_new_valist</code> methods all return a newly created
+ * <code>GError *</code> object instance, differing only in the way the
+ * message needs to be provided. For most usage though, it is preferrable
+ * to use the <code>gvir_set_error</code>, <code>gvir_set_error_literal</code>
+ * and <code>gvir_set_error_valist</code> methods. These all accept a
+ * <code>GError **</code> argument and take care to only fill it if it
+ * points to a non-NULL location.
+ *
+ * <example>
+ * <title>Reporting GLib errors with libvirt APIs</title>
+ * <programlisting><![CDATA[
+ * gboolean myapp_start_guest(const gchar *xml, GError **error)
+ * {
+ * if (virDomainCreate(conn, xml, 0) < 0) {
+ * gvir_set_error_literal(error, "Unable to start virtual machine");
+ * return FALSE;
+ * }
+ *
+ * return TRUE;
+ * }
+ * ]]></programlisting>
+ * </example>
+ *
+ */
+
+/**
+ * gvir_error_new:
* @domain: error domain
* @code: error code
* @format: printf()-style format for error message
- * @Varargs: parameters for message format
+ * @...: parameters for message format
*
* Creates a new #GError with the given @domain and @code,
* and a message formatted with @format.
@@ -61,7 +101,7 @@ GError *gvir_error_new(GQuark domain,
}
/**
- * gvir_error_new_literal: (skip)
+ * gvir_error_new_literal:
* @domain: error domain
* @code: error code
* @message: error message
@@ -99,7 +139,7 @@ GError *gvir_error_new_literal(GQuark domain,
}
/**
- * gvir_error_new_valist: (skip)
+ * gvir_error_new_valist:
* @domain: error domain
* @code: error code
* @format: printf()-style format for error message
@@ -129,12 +169,12 @@ GError *gvir_error_new_valist(GQuark domain,
/**
- * gvir_set_error: (skip)
+ * gvir_set_error:
* @error: pointer to error location
* @domain: error domain
* @code: error code
* @format: printf()-style format for error message
- * @Varargs: parameters for message format
+ * @...: parameters for message format
*
* If @error is NULL this does nothing. Otherwise it
* creates a new #GError with the given @domain and @code,
@@ -164,7 +204,7 @@ void gvir_set_error(GError **error,
/**
- * gvir_set_error_literal: (skip)
+ * gvir_set_error_literal:
* @error: pointer to error location
* @domain: error domain
* @code: error code
@@ -190,7 +230,7 @@ void gvir_set_error_literal(GError **error,
/**
- * gvir_set_error_valist: (skip)
+ * gvir_set_error_valist:
* @error: pointer to error location
* @domain: error domain
* @code: error code
diff --git a/libvirt-glib/libvirt-glib-event.c b/libvirt-glib/libvirt-glib-event.c
index 6d54b10..94f4de8 100644
--- a/libvirt-glib/libvirt-glib-event.c
+++ b/libvirt-glib/libvirt-glib-event.c
@@ -31,6 +31,53 @@
#include "libvirt-glib/libvirt-glib.h"
+/**
+ * SECTION:libvirt-glib-event
+ * @short_description: Integrate libvirt with the GMain event framework
+ * @title: Event loop
+ * @stability: Stable
+ * @include: libvirt-glib/libvirt-glib.h
+ *
+ * The libvirt API has the ability to provide applications with asynchronous
+ * notifications of interesting events. To enable this functionality though,
+ * applications must provide libvirt with an event loop implementation. The
+ * libvirt-glib API provides such an implementation, which naturally integrates
+ * with the GMain event loop framework.
+ *
+ * To enable use of the GMain event loop glue, the <code>gvir_event_register()</code>
+ * should be invoked. Once this is done, it is mandatory to have the default
+ * GMain event loop run by a thread in the application, usually the primary
+ * thread, eg by using <code>gtk_main()</code> or <code>g_application_run()</code>
+ *
+ * <example>
+ * <title>Registering for events with a GTK application</title>
+ * <programlisting><![CDATA[
+ * int main(int argc, char **argv) {
+ * ...setup...
+ * gvir_event_register();
+ * ...more setup...
+ * gtk_main();
+ * return 0;
+ * }
+ * ]]></programlisting>
+ * </example>
+ *
+ * <example>
+ * <title>Registering for events using Appplication</title>
+ * <programlisting><![CDATA[
+ * int main(int argc, char **argv) {
+ * ...setup...
+ * GApplication *app = ...create some impl of GApplication...
+ * gvir_event_register();
+ * ...more setup...
+ * g_application_run(app);
+ * return 0;
+ * }
+ * ]]></programlisting>
+ * </example>
+ */
+
+
#if GLIB_CHECK_VERSION(2, 31, 0)
#define g_mutex_new() g_new0(GMutex, 1)
#endif
@@ -414,6 +461,24 @@ static gpointer event_register_once(gpointer data G_GNUC_UNUSED)
return NULL;
}
+
+/**
+ * gvir_event_register:
+ *
+ * Registers a libvirt event loop implementation that is backed
+ * by the default <code>GMain</code> context. If invoked more
+ * than once this method will be a no-op. Applications should,
+ * however, take care not to register any another non-GLib
+ * event loop with libvirt.
+ *
+ * After invoking this method, it is mandatory to run the
+ * default GMain event loop. Typically this can be satisfied
+ * by invoking <code>gtk_main</code> or <code>g_application_run</code>
+ * in the application's main thread. Failure to run the event
+ * loop will mean no libvirt events get dispatched, and the
+ * libvirt keepalive timer will kill off libvirt connections
+ * frequently.
+ */
void gvir_event_register(void)
{
static GOnce once = G_ONCE_INIT;
diff --git a/libvirt-glib/libvirt-glib-main.c b/libvirt-glib/libvirt-glib-main.c
index 0cb2dd5..3389de9 100644
--- a/libvirt-glib/libvirt-glib-main.c
+++ b/libvirt-glib/libvirt-glib-main.c
@@ -29,6 +29,36 @@
#include "libvirt-glib-main.h"
+/**
+ * SECTION:libvirt-glib-main
+ * @short_description: Initialize the library
+ * @title: Library initialization
+ * @stability: Stable
+ * @include: libvirt-glib/libvirt-glib.h
+ *
+ * The Libvirt GLib library provides glue to integrate core libvirt
+ * infrastructure with the GLib library. This enables consistent
+ * error reporting procedures and a common event loop implementation
+ * for applications.
+ *
+ * Before using any functions in the Libvirt GLib library, it must be initialized
+ * by calling <code>gvir_init</code> or <code>gvir_init_check</code>.
+ *
+ * <example>
+ * <title>Initializing the Libvirt GLib library</title>
+ * <programlisting><![CDATA[
+ * int main(int argc, char **argv) {
+ * ...setup...
+ * gvir_init(&argc, &argv);
+ * ...more setup...
+ * gtk_main();
+ * return 0;
+ * }
+ * ]]></programlisting>
+ * </example>
+ *
+ */
+
static void
gvir_error_func(gpointer opaque G_GNUC_UNUSED,
virErrorPtr err)
@@ -37,6 +67,33 @@ gvir_error_func(gpointer opaque G_GNUC_UNUSED,
}
+
+/**
+ * gvir_init:
+ * @argc: (inout): Address of the argc parameter of your main() function (or 0
+ * if argv is NULL). This will be changed if any arguments were handled.
+ * @argv: (array length=argc) (inout) (allow-none): Address of the
+ * <parameter>argv</parameter> parameter of main(), or %NULL. Any options
+ * understood by GTK+ are stripped before return.
+ *
+ * Call this function before using any other Libvirt GLib functions in your applications.
+ * It will initialize everything needed to operate the toolkit and parses some standard
+ * command line options.
+ *
+ * Although you are expected to pass the @argc, @argv parameters from main() to this
+ * function, it is possible to pass NULL if @argv is not available or commandline
+ * handling is not required.
+ *
+ * @argc and @argv are adjusted accordingly so your own code will never see those
+ * standard arguments.
+ *
+ * This method will also turn on debug logging of the library if the
+ * <literal>LIBVIRT_GLIB_DEBUG</literal> environment variable is set.
+ *
+ * This function will terminate your program if it was unable to initialize
+ * for some reason. If you want the program to fall back to an alternate
+ * mode of operation call <code>gvir_init_check</code> instead.
+ */
void gvir_init(int *argc,
char ***argv)
{
@@ -58,6 +115,25 @@ static void gvir_log_handler(const gchar *log_domain G_GNUC_UNUSED,
}
+/**
+ * gvir_init_check:
+ * @argc: (inout): Address of the argc parameter of your main() function (or 0
+ * if argv is NULL). This will be changed if any arguments were handled.
+ * @argv: (array length=argc) (inout) (allow-none): Address of the
+ * <parameter>argv</parameter> parameter of main(), or %NULL. Any options
+ * understood by GTK+ are stripped before return.
+ * @err: filled with the error information if initialized failed.
+ *
+ * This function does the same work as gvir_init() with only a single
+ * change: It does not terminate the program if the Libvirt GLib library
+ * can't be initialized. Instead it returns %FALSE on failure.
+ *
+ * This way the application can fall back to some other mode of
+ * operation.
+ *
+ * Return value: %TRUE if the library was successfully initialized,
+ * %FALSE otherwise
+ */
gboolean gvir_init_check(int *argc G_GNUC_UNUSED,
char ***argv G_GNUC_UNUSED,
GError **err G_GNUC_UNUSED)
--
1.7.10
12 years, 6 months
[libvirt] [PATCH] Ensure libvirt_lxc process loads the live XML config
by Daniel P. Berrange
From: "Daniel P. Berrange" <berrange(a)redhat.com>
Currently the libvirt_lxc process uses VIR_DOMAIN_XML_INACTIVE
when loading the XML for the container. This means it looses
any dynamic data such as the, just allocated, SELinux label.
Further there is an inconsistency in the libvirt LXC driver
whereby it saves the live config XML and then later overwrites
the file with the live status XML instead. Add a comment about
this for future reference.
* src/lxc/lxc_controller.c: Remove VIR_DOMAIN_XML_INACTIVE
when loading XML
* src/lxc/lxc_driver.c: Add comment about inconsistent
config file formats
Signed-off-by: Daniel P. Berrange <berrange(a)redhat.com>
---
src/lxc/lxc_controller.c | 2 +-
src/lxc/lxc_driver.c | 14 ++++++--------
2 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/src/lxc/lxc_controller.c b/src/lxc/lxc_controller.c
index 2617423..1e3ec30 100644
--- a/src/lxc/lxc_controller.c
+++ b/src/lxc/lxc_controller.c
@@ -1781,7 +1781,7 @@ int main(int argc, char *argv[])
if ((def = virDomainDefParseFile(caps, configFile,
1 << VIR_DOMAIN_VIRT_LXC,
- VIR_DOMAIN_XML_INACTIVE)) == NULL)
+ 0)) == NULL)
goto cleanup;
if (def->nnets != nveths) {
diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c
index 7e7affd..ffdd4ac 100644
--- a/src/lxc/lxc_driver.c
+++ b/src/lxc/lxc_driver.c
@@ -1955,17 +1955,15 @@ static int lxcVmStart(virConnectPtr conn,
lxcProcessAutoDestroyAdd(driver, vm, conn) < 0)
goto error;
- /*
- * Again, need to save the live configuration, because the function
- * requires vm->def->id != -1 to save tty info surely.
- */
- if (virDomainSaveConfig(driver->stateDir, vm->def) < 0)
- goto error;
-
if (virDomainObjSetDefTransient(driver->caps, vm, false) < 0)
goto error;
- /* Write domain status to disk. */
+ /* Write domain status to disk.
+ *
+ * XXX: Earlier we wrote the plain "live" domain XML to this
+ * location for the benefit of libvirt_lxc. We're now overwriting
+ * it with the live status XML instead. This is a (currently
+ * harmless) inconsistency we should fix one day */
if (virDomainSaveStatus(driver->caps, driver->stateDir, vm) < 0)
goto error;
--
1.7.10
12 years, 6 months
[libvirt] [PATCH] util: Avoid libvirtd crash
by Alex Jia
In fact, the 'tapfd' is always NULL, the function 'virNetDevTapCreate()' hasn't
assign 'fd' to 'tapfd', when the function 'virNetDevSetMAC()' is failed then
goto 'error' lable, finally, the VIR_FORCE_CLOSE() will deref a NULL 'tapfd'.
* util/virnetdevtap.c (virNetDevTapCreateInBridgePort): fix a NULL pointer derefing.
* How to reproduce?
$ cat > /tmp/net.xml <<EOF
<network>
<name>test</name>
<forward mode='nat'/>
<bridge name='br1' stp='off' delay='1' />
<mac address='00:00:00:00:00:00'/>
<ip address='192.168.100.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.100.2' end='192.168.100.254' />
</dhcp>
</ip>
</network>
EOF
$ virsh net-define /tmp/net.xml
$ virsh net-start test
error: Failed to start network brTest
error: End of file while reading data: Input/output error
Signed-off-by: Alex Jia <ajia(a)redhat.com>
---
src/util/virnetdevtap.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/src/util/virnetdevtap.c b/src/util/virnetdevtap.c
index 0b3ac46..5d21164 100644
--- a/src/util/virnetdevtap.c
+++ b/src/util/virnetdevtap.c
@@ -341,7 +341,8 @@ int virNetDevTapCreateInBridgePort(const char *brname,
return 0;
error:
- VIR_FORCE_CLOSE(*tapfd);
+ if (tapfd)
+ VIR_FORCE_CLOSE(*tapfd);
return errno;
}
--
1.7.1
12 years, 6 months