[libvirt] [PATCH 2/5] daemonize qemu processes
by Guido Günther
Make sure vms don't get killed when the libvirtd quits unexpectedly.
Needs the previous patch since it looks at the pid file.
---
src/qemu_driver.c | 36 ++++++++++++++++++++++++------------
1 files changed, 24 insertions(+), 12 deletions(-)
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
index a2e573e..7804094 100644
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -858,6 +858,7 @@ static int qemudStartVMDaemon(virConnectPtr conn,
const char *emulator;
uid_t uid = geteuid();
mode_t logmode;
+ pid_t child;
FD_ZERO(&keepfd);
@@ -988,12 +989,26 @@ static int qemudStartVMDaemon(virConnectPtr conn,
for (i = 0 ; i < ntapfds ; i++)
FD_SET(tapfds[i], &keepfd);
- ret = virExec(conn, argv, progenv, &keepfd, &vm->pid,
+ ret = virExec(conn, argv, progenv, &keepfd, &child,
vm->stdin_fd, &vm->stdout_fd, &vm->stderr_fd,
- VIR_EXEC_NONBLOCK);
- if (ret == 0)
+ VIR_EXEC_NONBLOCK | VIR_EXEC_DAEMON);
+
+ /* wait for qemu process to to show up */
+ if (ret == 0) {
+ int retries = 100;
+ while (retries) {
+ if ((ret = virFileReadPid(driver->stateDir, vm->def->name, &vm->pid)) == 0)
+ break;
+ usleep(10*1000);
+ retries--;
+ }
+ if (ret)
+ qemudLog(QEMUD_WARN, _("Domain %s didn't show up\n"), vm->def->name);
+ }
+
+ if (ret == 0) {
vm->state = migrateFrom ? VIR_DOMAIN_PAUSED : VIR_DOMAIN_RUNNING;
- else
+ } else
vm->def->id = -1;
for (i = 0 ; argv[i] ; i++)
@@ -1069,7 +1084,9 @@ static void qemudShutdownVMDaemon(virConnectPtr conn ATTRIBUTE_UNUSED,
qemudLog(QEMUD_INFO, _("Shutting down VM '%s'\n"), vm->def->name);
- kill(vm->pid, SIGTERM);
+ if (kill(vm->pid, SIGTERM) < 0)
+ qemudLog(QEMUD_ERROR, _("Failed to send SIGTERM to %s (%d): %s\n"),
+ vm->def->name, vm->pid, strerror(errno));
qemudVMData(driver, vm, vm->stdout_fd);
qemudVMData(driver, vm, vm->stderr_fd);
@@ -1089,13 +1106,8 @@ static void qemudShutdownVMDaemon(virConnectPtr conn ATTRIBUTE_UNUSED,
vm->stderr_fd = -1;
vm->monitor = -1;
- if (waitpid(vm->pid, NULL, WNOHANG) != vm->pid) {
- kill(vm->pid, SIGKILL);
- if (waitpid(vm->pid, NULL, 0) != vm->pid) {
- qemudLog(QEMUD_WARN,
- "%s", _("Got unexpected pid, damn\n"));
- }
- }
+ /* shut it off for sure */
+ kill(vm->pid, SIGKILL);
vm->pid = -1;
vm->def->id = -1;
--
1.6.0.2
16 years, 3 months
[libvirt] [PATCH] Fix !SASL qemud compile
by john.levon@sun.com
# HG changeset patch
# User john.levon(a)sun.com
# Date 1229980020 28800
# Node ID 4fbf7139ca42757d771f03578e91038bf28a5e0e
# Parent fd97ec8e5799120ebf5ea9ed73d681c6d1386970
Fix !SASL qemud compile
Replace qemudLog() with ERROR0()
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/qemud/remote.c b/qemud/remote.c
--- a/qemud/remote.c
+++ b/qemud/remote.c
@@ -2968,7 +2968,7 @@ remoteDispatchAuthSaslInit (struct qemud
void *args ATTRIBUTE_UNUSED,
remote_auth_sasl_init_ret *ret ATTRIBUTE_UNUSED)
{
- qemudLog(QEMUD_ERR, "%s", _("client tried unsupported SASL init request"));
+ ERROR0(_("client tried unsupported SASL init request"));
remoteDispatchAuthError(rerr);
return -1;
}
@@ -2981,7 +2981,7 @@ remoteDispatchAuthSaslStart (struct qemu
remote_auth_sasl_start_args *args ATTRIBUTE_UNUSED,
remote_auth_sasl_start_ret *ret ATTRIBUTE_UNUSED)
{
- qemudLog(QEMUD_ERR, "%s", _("client tried unsupported SASL start request"));
+ ERROR0(_("client tried unsupported SASL start request"));
remoteDispatchAuthError(rerr);
return -1;
}
@@ -2994,7 +2994,7 @@ remoteDispatchAuthSaslStep (struct qemud
remote_auth_sasl_step_args *args ATTRIBUTE_UNUSED,
remote_auth_sasl_step_ret *ret ATTRIBUTE_UNUSED)
{
- qemudLog(QEMUD_ERR, "%s", _("client tried unsupported SASL step request"));
+ ERROR0(_("client tried unsupported SASL step request"));
remoteDispatchAuthError(rerr);
return -1;
}
16 years, 3 months
[libvirt] [PATCH] Make mntent.h specific to the FS storage backend
by john.levon@sun.com
# HG changeset patch
# User john.levon(a)sun.com
# Date 1229789393 28800
# Node ID c433c57ef39b2c343653910df84130c8849a7c11
# Parent 100de621beed6e146b239df3691bd426090955b4
Make mntent.h specific to the FS storage backend
It's Linux specific, so for now, put it behind a WITH_STORAGE_FS guard.
Signed-off-by: John Levon <john.levon(a)sun.com>
diff --git a/src/storage_backend_fs.c b/src/storage_backend_fs.c
--- a/src/storage_backend_fs.c
+++ b/src/storage_backend_fs.c
@@ -31,7 +31,6 @@
#include <errno.h>
#include <fcntl.h>
#include <unistd.h>
-#include <mntent.h>
#include <string.h>
#include <libxml/parser.h>
@@ -242,6 +241,9 @@ static int virStorageBackendProbeFile(vi
}
#if WITH_STORAGE_FS
+
+#include <mntent.h>
+
struct _virNetfsDiscoverState {
const char *host;
virStoragePoolSourceList list;
16 years, 3 months
[libvirt] [PATCH] virAsprintf cleanup
by Guido Günther
Hi,
please find a possible asprintf vs. virAsprintf cleanup attached. There
were several occations where the result of a failed asprintf was used.
Cheers,
-- Guido
16 years, 3 months
Re: [libvirt] KVM/qemu: problems with autostart of vms with non-bridged nets
by Gerd v. Egidy
> > I came up with the attached patch to fix this for me, but
> > a) I'm not sure if it is a clean use of the api to call virConnectOpen()
> > from within a state-initializer function
> > b) This is just for qemu/kvm, I haven't looked at any other drivers
> >
> > It would be nice if an experienced libvirt-developer could take a look at
> > this. Thank you very much.
>
> Thanks for the bug report & patch.
>
> Did this patch actually make it work for you ? AFAICT, there's a problem
> even earlier, which is that we are doing autostart of the virtual machines,
> before autostart of the networks and storage pools, so I'm not sure that
> this patch is sufficient.
This patch alone not, but this patch + the one in my first mail
(see https://www.redhat.com/archives/libvir-list/2008-November/msg00457.html)
together make it work for me. The first patch fixes the autostart order, the
second one adds the necessary conn structure.
Kind regards,
Gerd
--
Address (better: trap) for people I really don't want to get mail from:
james(a)cactusamerica.com
16 years, 3 months
[libvirt] libvirtd crashing with network bridge configuration
by Emre Erenoglu
Dear Developers, Users,
I'm trying to package libvirt for our distribution, however, having some
problems past the libvirt 0.4.3 series. Everything compiles and installs
fine.
With versions above and including 0.5.1, I'm getting the following errors in
the dmesg output:
virbr0: Dropping NETIF_F_UFO since no NETIF_F_HW_CSUM
feature.
virbr0: starting userspace STP failed, starting kernel
STP
sysfs: duplicate filename '0' can not be
created
------------[ cut here
]------------
WARNING: at fs/sysfs/dir.c:424
sysfs_add_one+0x34/0xa6()
Modules linked in: ipt_MASQUERADE iptable_nat nf_nat nf_conntrack_ipv4
xt_state nf_conntrack ipt_REJECT xt_tcpudp iptable_filter ip_tables x_tables
microcode firmware_class acpi_cpufreq cpufreq_powersave cpufreq_userspace
ipv6 bridge fuse loop tun kvm_intel kvm coretemp w83627ehf hwmon_vid hwmon
snd_hda_intel nvidia(P) snd_seq_dummy snd_seq_oss snd_seq_midi_event joydev
snd_seq rtc_cmos rtc_core rtc_lib snd_seq_device i2c_i801 iTCO_wdt usbhid
serio_raw snd_pcm_oss snd_mixer_oss hid iTCO_vendor_support snd_pcm
ff_memless snd_timer snd_page_alloc thermal atl1 snd_hwdep processor
intel_agp snd button mii agpgart i2c_core soundcore sg ext3 jbd mbcache
raid456 async_xor async_memcpy async_tx xor raid10 raid1 raid0 dm_mod sd_mod
sr_mod cdrom usb_storage pata_jmicron ehci_hcd uhci_hcd usbcore ohci1394
ieee1394 pata_acpi ahci ata_generic libata scsi_mod
dock
Pid: 3605, comm: libvirtd Tainted: P 2.6.25.20-113
#1
[<c02d60e6>] ?
printk+0xf/0x11
[<c0122e01>]
warn_on_slowpath+0x41/0x67
[<c01dbae8>] ?
vsnprintf+0x287/0x40f
[<c012352e>] ?
release_console_sem+0x194/0x19c
[<c01d7e32>] ?
ida_get_new_above+0xd0/0x171
[<c0185afb>] ?
find_inode+0x1f/0x5b
[<c01afde8>] ?
sysfs_ilookup_test+0x0/0x11
[<c0185bfb>] ?
ifind+0x32/0x76
[<c01b00ca>]
sysfs_add_one+0x34/0xa6
[<c01b05b2>]
create_dir+0x43/0x72
[<c01b060e>]
sysfs_create_dir+0x2d/0x41
[<c01d85de>] ?
kobject_get+0x12/0x17
[<c01d86dc>]
kobject_add_internal+0xa9/0x14a
[<c01d8811>]
kobject_add_varg+0x35/0x41
[<c01d883d>]
kobject_init_and_add+0x20/0x22
[<c012ae70>]
uids_user_create+0x36/0x5b
[<c012b028>] alloc_uid+0xf3/0x1b6
[<c01486c6>] copy_user_ns+0x59/0xaf
[<c0136833>] create_new_namespaces+0xe9/0x196
[<c013697e>] copy_namespaces+0x45/0x73
[<c0122152>] copy_process+0xba9/0x11e5
[<c012283d>] do_fork+0xaf/0x1e4
[<c0103428>] sys_clone+0x1f/0x21
[<c0104a2e>] syscall_call+0x7/0xb
[<c02d0000>] ? pci_fixup_msi_k8t_onboard_sound+0x68/0x98
=======================
---[ end trace e8211acaf4c7288d ]---
kobject_add_internal failed for 0 with -EEXIST, don't try to register things
with the same name in the same directory.
Pid: 3605, comm: libvirtd Tainted: P 2.6.25.20-113 #1
[<c01d876b>] kobject_add_internal+0x138/0x14a
[<c01d8811>] kobject_add_varg+0x35/0x41
[<c01d883d>] kobject_init_and_add+0x20/0x22
[<c012ae70>] uids_user_create+0x36/0x5b
[<c012b028>] alloc_uid+0xf3/0x1b6
[<c01486c6>] copy_user_ns+0x59/0xaf
[<c0136833>] create_new_namespaces+0xe9/0x196
[<c013697e>] copy_namespaces+0x45/0x73
[<c0122152>] copy_process+0xba9/0x11e5
[<c012283d>] do_fork+0xaf/0x1e4
[<c0103428>] sys_clone+0x1f/0x21
[<c0104a2e>] syscall_call+0x7/0xb
[<c02d0000>] ? pci_fixup_msi_k8t_onboard_sound+0x68/0x98
=======================
virbr0: no IPv6 routers present
ps ax shows the following output right after the service is started:
3605 ? S 0:00 /usr/sbin/libvirtd --daemon
3624 ? Z 0:00 [libvirtd] <defunct>
If I don't enable any network at /etc/libvirt/qemu/networks/autostart, then
there's no error.
Any clues are appreciated, I'm unable to proceed with it.
Best Regards.
Emre
16 years, 3 months