Re: [libvirt] [PATCH] 528575 avoid libvirtd crash on LCX domain autostart

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Wed, Oct 21, 2009 at 07:31:11PM +0900, Ryota Ozaki wrote:
> On Wed, Oct 21, 2009 at 6:55 PM, Daniel P. Berrange <berrange@xxxxxxxxxx> wrote:
> > On Wed, Oct 21, 2009 at 11:52:42AM +0200, Daniel Veillard wrote:
> >>   https://bugzilla.redhat.com/show_bug.cgi?id=528575
> >>
> >> virsh -c lxc:/// autostart vm1
> >>
> >> crash the daemon because the driver autostartDir is never initialized
> >> and we do a NULL dereference. The enclosed patch is trivial and avoid
> >> the crash, but ...
> >>
> >> [root@paphio ~]# virsh -c lxc:/// dominfo vm1
> >> Id:             -
> >> Name:           vm1
> >> UUID:           d320f760-7541-6633-fd42-4f984fca9f51
> >> OS Type:        exe
> >> State:          shut off
> >> CPU(s):         1
> >> Max memory:     500000 kB
> >> Used memory:    500000 kB
> >> Autostart:      enable
> >>
> >> while the domain is properly flagged as autostarting it doesn't seem to
> >> actually autostart, and the driver->autostartDir directory is not
> >> created on the fly as I would expect, i.e.
> >>   /etc/libvirt/lxc/autostart/
> >> still doesn't exist and the domain is marked as off and Autostart: enable
> >
> > That's because of :
> >
> >> diff --git a/src/lxc/lxc_conf.h b/src/lxc/lxc_conf.h
> >> index 6e4c855..eca8c7c 100644
> >> --- a/src/lxc/lxc_conf.h
> >> +++ b/src/lxc/lxc_conf.h
> >> @@ -36,6 +36,7 @@
> >>  #define LXC_CONFIG_DIR SYSCONF_DIR "/libvirt/lxc"
> >>  #define LXC_STATE_DIR LOCAL_STATE_DIR "/run/libvirt/lxc"
> >>  #define LXC_LOG_DIR LOCAL_STATE_DIR "/log/libvirt/lxc"
> >> +#define LXC_AUTOSTART_DIR LOCAL_STATE_DIR "/libvirt/lxc/autostart"
> >
> > LOCAL_STATE_DIR expands to /var

  Dohhh

> > The autostart dir should be  defined as
> >
> >  #define LXC_AUTOSTART_DIR  LXC_CONFIG_DIR "/autostart"

  and I had the process under gdb, I didn't even looked at the value :-\

> Yes, that's correct. I've confirmed it fixes the defect in my environment.
> So ACK to the revised one.
> 
> BTW, actually I've never used autostart feature though, when autostart-enabled
> domains boot up? 'service libvirtd restart' seems not kicking my lxc...

  Thanks a lot for the quick feedback, enclosed patch applied !

Daniel

-- 
Daniel Veillard      | libxml Gnome XML XSLT toolkit  http://xmlsoft.org/
daniel@xxxxxxxxxxxx  | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library  http://libvirt.org/
commit 09c64d0072857922aabff90392b3334aa2d1fde5
Author: Daniel Veillard <veillard@xxxxxxxxxx>
Date:   Wed Oct 21 13:32:20 2009 +0200

    528575 avoid libvirtd crash on LCX domain autostart
    
    https://bugzilla.redhat.com/show_bug.cgi?id=528575
    virsh -c lxc:/// autostart vm1
    was crashing the daemon
    
    * src/lxc/lxc_conf.h src/lxc/lxc_conf.c: initialize the driver
      autostartDir to avoid a NULL reference and implement autostart for LXC

diff --git a/src/lxc/lxc_conf.c b/src/lxc/lxc_conf.c
index de059bd..74dc367 100644
--- a/src/lxc/lxc_conf.c
+++ b/src/lxc/lxc_conf.c
@@ -102,6 +102,9 @@ int lxcLoadDriverConfig(lxc_driver_t *driver)
         goto no_memory;
     if ((driver->logDir = strdup(LXC_LOG_DIR)) == NULL)
         goto no_memory;
+    if ((driver->autostartDir = strdup(LXC_AUTOSTART_DIR)) == NULL)
+        goto no_memory;
+
 
     if ((filename = strdup(SYSCONF_DIR "/libvirt/lxc.conf")) == NULL)
         goto no_memory;
diff --git a/src/lxc/lxc_conf.h b/src/lxc/lxc_conf.h
index 6e4c855..499617f 100644
--- a/src/lxc/lxc_conf.h
+++ b/src/lxc/lxc_conf.h
@@ -36,6 +36,7 @@
 #define LXC_CONFIG_DIR SYSCONF_DIR "/libvirt/lxc"
 #define LXC_STATE_DIR LOCAL_STATE_DIR "/run/libvirt/lxc"
 #define LXC_LOG_DIR LOCAL_STATE_DIR "/log/libvirt/lxc"
+#define LXC_AUTOSTART_DIR LXC_CONFIG_DIR "/autostart"
 
 typedef struct __lxc_driver lxc_driver_t;
 struct __lxc_driver {
--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]