[libvirt] [PATCH 13/17] qemu: Let tests override waiting time for device unplug
Daniel P. Berrange
berrange at redhat.com
Tue Aug 20 13:33:21 UTC 2013
On Thu, Aug 01, 2013 at 09:28:22PM +0200, Jiri Denemark wrote:
> We don't want tests to wait 5 seconds for an event which we know will
> never come.
> ---
> src/Makefile.am | 1 +
> src/qemu/qemu_hotplug.c | 10 ++++++----
> src/qemu/qemu_hotplugpriv.h | 31 +++++++++++++++++++++++++++++++
> 3 files changed, 38 insertions(+), 4 deletions(-)
> create mode 100644 src/qemu/qemu_hotplugpriv.h
>
> diff --git a/src/Makefile.am b/src/Makefile.am
> index 88dc5fe..3f410da 100644
> --- a/src/Makefile.am
> +++ b/src/Makefile.am
> @@ -633,6 +633,7 @@ QEMU_DRIVER_SOURCES = \
> qemu/qemu_cgroup.c qemu/qemu_cgroup.h \
> qemu/qemu_hostdev.c qemu/qemu_hostdev.h \
> qemu/qemu_hotplug.c qemu/qemu_hotplug.h \
> + qemu/qemu_hotplugpriv.h \
> qemu/qemu_conf.c qemu/qemu_conf.h \
> qemu/qemu_process.c qemu/qemu_process.h \
> qemu/qemu_processpriv.h \
> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> index f8bcc9a..f9d75dc 100644
> --- a/src/qemu/qemu_hotplug.c
> +++ b/src/qemu/qemu_hotplug.c
> @@ -25,6 +25,7 @@
> #include <config.h>
>
> #include "qemu_hotplug.h"
> +#include "qemu_hotplugpriv.h"
> #include "qemu_capabilities.h"
> #include "qemu_domain.h"
> #include "qemu_command.h"
> @@ -53,6 +54,10 @@
> #define VIR_FROM_THIS VIR_FROM_QEMU
> #define CHANGE_MEDIA_RETRIES 10
>
> +/* Wait up to 5 seconds for device removal to finish. */
> +unsigned long long qemuDomainRemoveDeviceWaitTime = 1000ull * 5;
> +
> +
> int qemuDomainChangeEjectableMedia(virQEMUDriverPtr driver,
> virDomainObjPtr vm,
> virDomainDiskDefPtr disk,
> @@ -2679,9 +2684,6 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver,
> }
>
>
> -/* Wait up to 5 seconds for device removal to finish. */
> -#define QEMU_REMOVAL_WAIT_TIME (1000ull * 5)
> -
> static void
> qemuDomainMarkDeviceForRemoval(virDomainObjPtr vm,
> virDomainDeviceInfoPtr info)
> @@ -2718,7 +2720,7 @@ qemuDomainWaitForDeviceRemoval(virDomainObjPtr vm)
>
> if (virTimeMillisNow(&until) < 0)
> return -1;
> - until += QEMU_REMOVAL_WAIT_TIME;
> + until += qemuDomainRemoveDeviceWaitTime;
>
> while (priv->unpluggingDevice) {
> if (virCondWaitUntil(&priv->unplugFinished,
> diff --git a/src/qemu/qemu_hotplugpriv.h b/src/qemu/qemu_hotplugpriv.h
> new file mode 100644
> index 0000000..e4a1164
> --- /dev/null
> +++ b/src/qemu/qemu_hotplugpriv.h
> @@ -0,0 +1,31 @@
> +/*
> + * qemu_hotplugpriv.h: private declarations for QEMU device hotplug management
> + *
> + * Copyright (C) 2013 Red Hat, Inc.
> + *
> + * 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, see
> + * <http://www.gnu.org/licenses/>.
> + *
> + */
> +
> +#ifndef __QEMU_HOTPLUGPRIV_H__
> +# define __QEMU_HOTPLUGPRIV_H__
> +
> +/*
> + * This header file should never be used outside unit tests.
> + */
> +
> +unsigned long long qemuDomainRemoveDeviceWaitTime;
Don't you need 'extern' here otherwise every .c file that includes
this header will allocate storage a new copy of this variable.
Daniel
--
|: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :|
|: http://libvirt.org -o- http://virt-manager.org :|
|: http://autobuild.org -o- http://search.cpan.org/~danberr/ :|
|: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|
More information about the libvir-list
mailing list