From af590c6636d56ec1148ad6eb74acf5f74562747422c0f10ec0dc21c65679b8bc Mon Sep 17 00:00:00 2001 From: OBS User buildservice-autocommit Date: Fri, 8 Apr 2011 12:58:49 +0000 Subject: [PATCH 1/2] Updating link to change in openSUSE:Factory/xen revision 128.0 OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=1ff8cdb13f147058d505e3494a575378 --- xen.spec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xen.spec b/xen.spec index 4c65b3d..4ef489b 100644 --- a/xen.spec +++ b/xen.spec @@ -75,7 +75,7 @@ BuildRequires: glibc-devel BuildRequires: kernel-source kernel-syms module-init-tools xorg-x11 %endif Version: 4.1.0_01 -Release: 2 +Release: 5 License: GPLv2+ Group: System/Kernel AutoReqProv: on From 58f0aa1c597d7caa1b5d98973a47fb59ae9ffde2ed28579bbb14d02f8dc050d4 Mon Sep 17 00:00:00 2001 From: James Fehlig Date: Mon, 11 Apr 2011 22:31:41 +0000 Subject: [PATCH 2/2] - bnc#685338: Fix porting of xend-domain-lock.patch - update scripts to use xl instead of xm: xen-updown.sh, init.xendomains, xmclone.sh - disable xend in openSuSE > 11.4 the xl command is the replacement for the xm command - mark runlevel scripts as config to preserve local changes by admin or dev during package update - enable xencommons runlevel script during upgrade if xend was already enabled - call /sbin/ldconfig directly in xen-libs post install scripts OBS-URL: https://build.opensuse.org/package/show/Virtualization/xen?expand=0&rev=110 --- init.xendomains | 19 ++-- xen-updown.sh | 3 +- xen.changes | 34 +++++++ xen.spec | 219 +++++++++++++++++++---------------------- xend-domain-lock.patch | 99 +++++++++++++++++++ xmclone.sh | 5 +- 6 files changed, 251 insertions(+), 128 deletions(-) diff --git a/init.xendomains b/init.xendomains index d146c63..face621 100644 --- a/init.xendomains +++ b/init.xendomains @@ -24,6 +24,7 @@ rc_reset LOCKFILE=/var/lock/subsys/xendomains XENDOM_CONFIG=/etc/sysconfig/xendomains RETCODE_FILE=/tmp/xendomains.rc.$$ +xm_cmd=xl . "$XENDOM_CONFIG" @@ -127,7 +128,7 @@ parseln() xm_list() { - TERM=vt100 xm list | grep -v '^Name *ID' + TERM=vt100 ${xm_cmd} list | grep -v '^Name *ID' } is_cfg_running() @@ -163,7 +164,7 @@ start() printed=1 for dom in "$XENDOMAINS_SAVE"/*; do echo -n " ${dom##*/}: " - xm restore "$dom" >/dev/null 2>&1 + ${xm_cmd} restore "$dom" >/dev/null 2>&1 if [ $? -ne 0 ]; then rc_failed else @@ -184,9 +185,9 @@ start() rc_status -s else if grep -q "^name" "$dom";then - xm create --quiet --defconfig "$dom" + ${xm_cmd} create --quiet --defconfig "$dom" elif grep -q "(name .*" "$dom";then - xm create --quiet --config "$dom" + ${xm_cmd} create --quiet --config "$dom" fi if [ $? -ne 0 ]; then rc_failed @@ -224,19 +225,19 @@ any_non_zombies() migrate_with_watchdog() { - (xm migrate "$@" ; echo $? > "$RETCODE_FILE") >/dev/null 2>&1 & + (${xm_cmd} migrate "$@" ; echo $? > "$RETCODE_FILE") >/dev/null 2>&1 & watchdog_xm $! } save_with_watchdog() { - (xm save "$@" ; echo $? > "$RETCODE_FILE") >/dev/null 2>&1 & + (${xm_cmd} save "$@" ; echo $? > "$RETCODE_FILE") >/dev/null 2>&1 & watchdog_xm $! } shutdown_with_watchdog() { - (xm shutdown -w "$@" ; echo $? > "$RETCODE_FILE") >/dev/null 2>&1 & + (${xm_cmd} shutdown -w "$@" ; echo $? > "$RETCODE_FILE") >/dev/null 2>&1 & watchdog_xm $! } @@ -309,7 +310,7 @@ stop() for sysrq in $XENDOMAINS_SYSRQ; do echo -n " $name: " echo -n "sending sysrq '$sysrq'... " - xm sysrq $id $sysrq + ${xm_cmd} sysrq $id $sysrq if [ $? -ne 0 ]; then rc_failed else @@ -323,7 +324,7 @@ stop() if is_zombie_state "$state"; then echo -n " $name: " echo -n "destroying zombie... " - xm destroy $id + ${xm_cmd} destroy $id rc_reset rc_status -v continue diff --git a/xen-updown.sh b/xen-updown.sh index 7bdb197..b8ae89f 100644 --- a/xen-updown.sh +++ b/xen-updown.sh @@ -12,6 +12,7 @@ usage () { exit $R_USAGE } +xm_cmd=xl ###################################################################### # change the working direcory and source some common files # @@ -94,7 +95,7 @@ parseln() xm_list() { - TERM=vt100 xm list | grep -v '^Name *ID' + TERM=vt100 ${xm_cmd} list | grep -v '^Name *ID' } # For the specified vm, return a list of vifs that are connected to $INTERFACE diff --git a/xen.changes b/xen.changes index 66c2848..7912883 100644 --- a/xen.changes +++ b/xen.changes @@ -1,3 +1,37 @@ +------------------------------------------------------------------- +Mon Apr 11 15:55:04 MDT 2011 - jfehlig@suse.de + +- bnc#685338: Fix porting of xend-domain-lock.patch + +------------------------------------------------------------------- +Mon Apr 11 19:33:34 CEST 2011 - ohering@suse.de + +- update scripts to use xl instead of xm: + xen-updown.sh, init.xendomains, xmclone.sh + +------------------------------------------------------------------- +Mon Apr 11 17:34:46 CEST 2011 - ohering@suse.de + +- disable xend in openSuSE > 11.4 + the xl command is the replacement for the xm command + +------------------------------------------------------------------- +Thu Apr 7 18:16:45 CEST 2011 - ohering@suse.de + +- mark runlevel scripts as config to preserve local changes by + admin or dev during package update + +------------------------------------------------------------------- +Thu Apr 7 18:11:14 CEST 2011 - ohering@suse.de + +- enable xencommons runlevel script during upgrade if xend was + already enabled + +------------------------------------------------------------------- +Thu Apr 7 17:50:23 CEST 2011 - ohering@suse.de + +- call /sbin/ldconfig directly in xen-libs post install scripts + ------------------------------------------------------------------- Thu Mar 31 12:41:24 UTC 2011 - coolo@novell.com diff --git a/xen.spec b/xen.spec index 4ef489b..bd31a16 100644 --- a/xen.spec +++ b/xen.spec @@ -1,5 +1,5 @@ # -# spec file for package xen +# spec file for package xen (Version 4.1.0_01) # # Copyright (c) 2011 SUSE LINUX Products GmbH, Nuernberg, Germany. # @@ -26,39 +26,44 @@ ExclusiveArch: %ix86 x86_64 %define xen_build_dir xen-4.1.0-testing %define with_kmp 1 %define with_stubdom 0 -BuildRequires: LibVNCServer-devel -BuildRequires: SDL-devel -BuildRequires: automake -BuildRequires: bin86 -BuildRequires: curl-devel -BuildRequires: dev86 -BuildRequires: graphviz -BuildRequires: latex2html -BuildRequires: libjpeg-devel -BuildRequires: libxml2-devel -BuildRequires: ncurses-devel -BuildRequires: openssl -BuildRequires: openssl-devel -BuildRequires: pciutils-devel -BuildRequires: python-devel -BuildRequires: texinfo -BuildRequires: transfig -BuildRequires: libbz2-devel +%if %suse_version > 1140 +%define with_xend 0 +%else +%define with_xend 1 +%endif +BuildRequires: LibVNCServer-devel +BuildRequires: SDL-devel +BuildRequires: automake +BuildRequires: bin86 +BuildRequires: curl-devel +BuildRequires: dev86 +BuildRequires: graphviz +BuildRequires: latex2html +BuildRequires: libjpeg-devel +BuildRequires: libxml2-devel +BuildRequires: ncurses-devel +BuildRequires: openssl +BuildRequires: openssl-devel +BuildRequires: pciutils-devel +BuildRequires: python-devel +BuildRequires: texinfo +BuildRequires: transfig +BuildRequires: libbz2-devel %if %suse_version >= 1120 -BuildRequires: xz-devel +BuildRequires: xz-devel %endif %if %suse_version <= 1110 -BuildRequires: pmtools +BuildRequires: pmtools %else -BuildRequires: acpica +BuildRequires: acpica %endif %if %suse_version >= 1030 -BuildRequires: texlive -BuildRequires: texlive-latex +BuildRequires: texlive +BuildRequires: texlive-latex %else -BuildRequires: te_ams -BuildRequires: te_latex -BuildRequires: tetex +BuildRequires: te_ams +BuildRequires: te_latex +BuildRequires: tetex %endif %ifarch x86_64 BuildRequires: glibc-32bit glibc-devel-32bit @@ -75,7 +80,7 @@ BuildRequires: glibc-devel BuildRequires: kernel-source kernel-syms module-init-tools xorg-x11 %endif Version: 4.1.0_01 -Release: 5 +Release: 1 License: GPLv2+ Group: System/Kernel AutoReqProv: on @@ -167,7 +172,7 @@ Patch370: xend-sysconfig.patch Patch371: domu-usb-controller.patch Patch372: usb-list.patch Patch373: xend-devid-or-name.patch -Patch374: suspend_evtchn_lock.patch +Patch374: suspend_evtchn_lock.patch # Patches for snapshot support Patch400: snapshot-ioemu-save.patch Patch401: snapshot-ioemu-restore.patch @@ -223,39 +228,38 @@ Patch651: ioemu-disable-scsi.patch Patch652: ioemu-disable-emulated-ide-if-pv.patch Patch700: hv_extid_compatibility.patch # FATE 310510 -Patch10001: xenpaging.tools_xenpaging_cleanup.patch -Patch10002: xenpaging.pageout_policy.patch -Patch10003: xenpaging.get_paged_frame.patch -Patch10004: xenpaging.makefile.patch -Patch10010: xenpaging.policy_linear.patch -Patch10011: xenpaging.pagefile.patch -Patch10012: xenpaging.xenpaging_init.patch -Patch10013: xenpaging.mem_paging_tool_qemu_flush_cache.patch -Patch10014: xenpaging.machine_to_phys_mapping.patch -Patch10015: xenpaging.populate_only_if_paged.patch -Patch10017: xenpaging.autostart.patch -Patch10018: xenpaging.signal_handling.patch -Patch10019: xenpaging.MRU_SIZE.patch -Patch10020: xenpaging.guest_remove_page.patch -Patch10021: xenpaging.mem_event_check_ring-free_requests.patch -Patch10022: xenpaging.blacklist.patch -Patch10023: xenpaging.autostart_delay.patch -Patch10024: xenpaging.page_already_populated.patch -Patch10025: xenpaging.notify_policy_only_once.patch -Patch10026: xenpaging.num_pages_equal_max_pages.patch -Patch10027: xenpaging.p2m_mem_paging_populate_if_p2m_ram_paged.patch -Patch10028: xenpaging.HVMCOPY_gfn_paged_out.patch -Patch10029: xenpaging.optimize_p2m_mem_paging_populate.patch -Patch10030: xenpaging.paging_prep_enomem.patch -Patch10031: xenpaging.print-arguments.patch -Patch10032: xenpaging.no_domain_id.patch -Patch10033: xenpaging.runtime_mru_size.patch -Patch10040: xenpaging.doc.patch +Patch10001: xenpaging.tools_xenpaging_cleanup.patch +Patch10002: xenpaging.pageout_policy.patch +Patch10003: xenpaging.get_paged_frame.patch +Patch10004: xenpaging.makefile.patch +Patch10010: xenpaging.policy_linear.patch +Patch10011: xenpaging.pagefile.patch +Patch10012: xenpaging.xenpaging_init.patch +Patch10013: xenpaging.mem_paging_tool_qemu_flush_cache.patch +Patch10014: xenpaging.machine_to_phys_mapping.patch +Patch10015: xenpaging.populate_only_if_paged.patch +Patch10017: xenpaging.autostart.patch +Patch10018: xenpaging.signal_handling.patch +Patch10019: xenpaging.MRU_SIZE.patch +Patch10020: xenpaging.guest_remove_page.patch +Patch10021: xenpaging.mem_event_check_ring-free_requests.patch +Patch10022: xenpaging.blacklist.patch +Patch10023: xenpaging.autostart_delay.patch +Patch10024: xenpaging.page_already_populated.patch +Patch10025: xenpaging.notify_policy_only_once.patch +Patch10026: xenpaging.num_pages_equal_max_pages.patch +Patch10027: xenpaging.p2m_mem_paging_populate_if_p2m_ram_paged.patch +Patch10028: xenpaging.HVMCOPY_gfn_paged_out.patch +Patch10029: xenpaging.optimize_p2m_mem_paging_populate.patch +Patch10030: xenpaging.paging_prep_enomem.patch +Patch10031: xenpaging.print-arguments.patch +Patch10032: xenpaging.no_domain_id.patch +Patch10033: xenpaging.runtime_mru_size.patch +Patch10040: xenpaging.doc.patch # Build patch Patch99999: tmp_build.patch Url: http://www.cl.cam.ac.uk/Research/SRG/netos/xen/ BuildRoot: %{_tmppath}/%{name}-%{version}-build -#%define pysite %(python -c "import distutils.sysconfig; print distutils.sysconfig.get_python_lib()") %define pyver %(python -c "import sys; print sys.version[:3]") %if %{?with_kmp}0 %suse_kernel_module_package -n xen um xen -f kmp_filelist @@ -714,6 +718,7 @@ tar xfj %{SOURCE2} -C $RPM_BUILD_DIR/%{xen_build_dir}/tools #%patch10040 -p1 %patch99999 -p1 + %build XEN_EXTRAVERSION=%version-%release XEN_EXTRAVERSION=${XEN_EXTRAVERSION#%{xvers}} @@ -726,9 +731,6 @@ make -C xenalyze.hg CC="gcc -I../xen/include" %{?_smp_mflags} make -C tools/include/xen-foreign %{?_smp_mflags} make tools docs %{?_smp_mflags} make -C tools/debugger/gdbsx -#### there are code problems that don't pass the 02-check-gcc-output, hence bitbucket -###env MAKE="make %{?_smp_mflags}" ./gdbbuild 1>/dev/null 2>/dev/null -###cd ../../.. %if %{?with_kmp}0 # pv driver modules export XL=/usr/src/linux @@ -748,9 +750,7 @@ done make -C tools/xen-utils-0.1 XEN_INTREE_BUILD=yes %install -test ! -z "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != "/" && rm -rf $RPM_BUILD_ROOT export CFLAGS="$RPM_OPT_FLAGS" -export RPM_OPT_FLAGS install_xen() { local ext="" @@ -776,8 +776,6 @@ make -C xen clean make -C xen install max_phys_cpus=%{max_cpus} pae=%{pae_enabled} debug=n crash_debug=n DESTDIR=$RPM_BUILD_ROOT %{?_smp_mflags} install_xen make -C xen clean -export CFLAGS="$RPM_OPT_FLAGS" -export RPM_OPT_FLAGS make -C tools/include/xen-foreign %{?_smp_mflags} # tools export XEN_PYTHON_NATIVE_INSTALL=1 @@ -812,7 +810,6 @@ make -C stubdom install \ DOCDIR=%{_defaultdocdir}/xen INCDIR=%{_includedir} mkdir -p $RPM_BUILD_ROOT/%{_defaultdocdir}/xen %ifarch x86_64 -ln -s /usr/lib/xen/boot/pv-grub-x86_32.gz $RPM_BUILD_ROOT/usr/lib/xen/boot/pv-grub-x86_32.gz ln -s /usr/lib/xen/bin/stubdom-dm $RPM_BUILD_ROOT/usr/lib64/xen/bin/stubdom-dm ln -s /usr/lib/xen/bin/stubdompath.sh $RPM_BUILD_ROOT/usr/lib64/xen/bin/stubdompath.sh %endif @@ -868,7 +865,6 @@ mkdir -p $RPM_BUILD_ROOT/var/lib/xen/dump mkdir -p $RPM_BUILD_ROOT/var/lib/xen/xend-db/domain mkdir -p $RPM_BUILD_ROOT/var/lib/xen/xend-db/migrate mkdir -p $RPM_BUILD_ROOT/var/lib/xen/xend-db/vnet -mkdir -p $RPM_BUILD_ROOT/var/lib/xen/xenpaging mkdir -p $RPM_BUILD_ROOT/var/log/xen ln -s /var/lib/xen/images $RPM_BUILD_ROOT/etc/xen/images # Bootloader @@ -889,7 +885,6 @@ rm -f $RPM_BUILD_ROOT/usr/share/xen/qemu/openbios-sparc32 rm -f $RPM_BUILD_ROOT/usr/share/xen/qemu/openbios-sparc64 rm -f $RPM_BUILD_ROOT/usr/share/xen/qemu/openbios-ppc rm -f $RPM_BUILD_ROOT/usr/sbin/netfix -#rm -f $RPM_BUILD_ROOT/%pysite/*.egg-info rm -f $RPM_BUILD_ROOT/%{_libdir}/python%{pyver}/site-packages/*.egg-info rm -rf $RPM_BUILD_ROOT/html rm -rf $RPM_BUILD_ROOT/usr/share/doc/xen/README.* @@ -919,13 +914,7 @@ rm -rf $RPM_BUILD_ROOT/%{_libdir}/debug %files libs %defattr(-,root,root) %{_libdir}/fs/ -%{_libdir}/libblktap.so.* -%{_libdir}/libflask.so.* -%{_libdir}/libfsimage.so.* -%{_libdir}/libxen*.so.* -%{_libdir}/libvhd.so.* -%{_libdir}/libxlutil.so.* -%{_libdir}/libblktapctl.so.* +%{_libdir}/*.so.* %files tools %defattr(-,root,root) @@ -990,18 +979,14 @@ rm -rf $RPM_BUILD_ROOT/%{_libdir}/debug %dir /var/lib/xen/xend-db/vnet %dir /var/lib/xenstored %dir /var/log/xen -/etc/init.d/xend -/etc/init.d/xendomains -/etc/init.d/xencommons -/etc/init.d/xen-watchdog +%config /etc/init.d/* %config /etc/logrotate.d/xen %dir %attr(700,root,root) /etc/xen /etc/xen/auto %config /etc/xen/examples /etc/xen/images /etc/xen/scripts -/etc/xen/cpupool -#/etc/xen/scripts/qemu-ifup +%config /etc/xen/cpupool /etc/xen/README* %config /etc/xen/vm %config(noreplace) /etc/xen/*.sxp @@ -1032,7 +1017,6 @@ rm -rf $RPM_BUILD_ROOT/%{_libdir}/debug %dir %{_datadir}/xen/man/man1 %dir %{_datadir}/xen/man/man8 %dir %{_datadir}/xen/qemu -#%dir %{_datadir}/xen/qemu/keymaps %{_datadir}/xen/*.dtd %{_datadir}/xen/qemu/* %{_datadir}/xen/man/man1/* @@ -1055,12 +1039,9 @@ rm -rf $RPM_BUILD_ROOT/%{_libdir}/debug #/usr/lib/xen/bin/xc_kexec %endif /usr/lib/xen/boot/hvmloader -#%pysite/xen/* %{_libdir}/python%{pyver}/site-packages/xen/* /usr/lib/xen/boot/domUloader.py -#%pysite/grub/* %{_libdir}/python%{pyver}/site-packages/grub/* -#%pysite/fsimage.so %{_libdir}/python%{pyver}/site-packages/fsimage.so %if %{?with_stubdom}0 /usr/lib/xen/boot/ioemu-stubdom.gz @@ -1078,29 +1059,10 @@ rm -rf $RPM_BUILD_ROOT/%{_libdir}/debug %files devel %defattr(-,root,root) -%{_libdir}/libblktap.a -%{_libdir}/libblktap.so -%{_libdir}/libflask.a -%{_libdir}/libflask.so -%{_libdir}/libfsimage.so -%{_libdir}/libxen*.a -%{_libdir}/libxen*.so -%{_libdir}/libvhd.a -%{_libdir}/libvhd.so -%{_libdir}/libxlutil.a -%{_libdir}/libxlutil.so -%{_libdir}/libblktapctl.a -%{_libdir}/libblktapctl.so +%{_libdir}/*.a +%{_libdir}/*.so +/usr/include/* /usr/bin/serial-split -/usr/include/blktaplib.h -/usr/include/fsimage* -/usr/include/xen*.h -/usr/include/xen/ -/usr/include/xs.h -/usr/include/xs_lib.h -/usr/include/libxl.h -/usr/include/_libxl_types.h -/usr/include/libxl_uuid.h %files doc-html %defattr(-,root,root) @@ -1110,12 +1072,36 @@ rm -rf $RPM_BUILD_ROOT/%{_libdir}/debug %defattr(-,root,root) %{_defaultdocdir}/xen/pdf -%clean -#test ! -z "$RPM_BUILD_ROOT" -a "$RPM_BUILD_ROOT" != "/" && rm -rf $RPM_BUILD_ROOT -#rm -rf $RPM_BUILD_DIR/%xen_build_dir - %post tools +%if %{?with_xend}0 +# with_xend +# enable both xm (xend based) and xl (libxl based) +if /bin/ls /etc/init.d/rc3.d/S??xend > /dev/null 2>&1 ; then + if ! /bin/ls /etc/init.d/rc3.d/S??xencommons > /dev/null 2>&1 ; then + echo "postin %{name}-tools: Forcing insserv xencommons during package upgrade because xend was enabled." + echo "postin %{name}-tools: with xend" + fi + %{fillup_and_insserv -Y -n xencommons xencommons} +else + %{fillup_and_insserv -y -n xencommons xencommons} +fi %{fillup_and_insserv -y -n xend xend} +%else +# without_xend +# disable xm (xend based) and enable only xl (libxl based) +if /bin/ls /etc/init.d/rc3.d/S??xend > /dev/null 2>&1 ; then + if ! /bin/ls /etc/init.d/rc3.d/S??xencommons > /dev/null 2>&1 ; then + echo "postin %{name}-tools: Forcing insserv xencommons during package upgrade because xend was enabled." + fi + echo "postin %{name}-tools: disabling xend in favor of xencommons. xm command replaced by xl." + %{stop_on_removal xend} + rm -fv /etc/init.d/rc?.d/???xend || : + %{fillup_and_insserv -Y -n xencommons xencommons} +else + %{fillup_and_insserv -y -n xencommons xencommons} +fi +%endif +# %{fillup_and_insserv -y -n xendomains xendomains} if [ -f /usr/bin/qemu-img ]; then if [ -f /usr/bin/qemu-img-xen ]; then @@ -1131,10 +1117,13 @@ if [ -f /usr/bin/qemu-nbd ]; then fi %preun tools -%{stop_on_removal xendomains xend} +%{stop_on_removal xendomains xend xencommons} %postun tools +%if %{?with_xend}0 +# with_xend %{restart_on_update xend} +%endif %{insserv_cleanup} if [ -f /usr/bin/qemu-img-xen ]; then rm /usr/bin/qemu-img-xen @@ -1143,10 +1132,8 @@ if [ -f /usr/bin/qemu-nbd-xen ]; then rm /usr/bin/qemu-nbd-xen fi -%post libs -/sbin/ldconfig +%post libs -p /sbin/ldconfig -%postun libs -/sbin/ldconfig +%postun libs -p /sbin/ldconfig %changelog diff --git a/xend-domain-lock.patch b/xend-domain-lock.patch index dff6545..10b340c 100644 --- a/xend-domain-lock.patch +++ b/xend-domain-lock.patch @@ -282,3 +282,102 @@ Index: xen-4.1.0-testing/tools/hotplug/Linux/vm-monitor +elif [ $0 = "$basedir/vm-monitor" ]; then + monitor $* +fi +Index: xen-4.1.0-testing/tools/python/xen/xend/XendDomainInfo.py +=================================================================== +--- xen-4.1.0-testing.orig/tools/python/xen/xend/XendDomainInfo.py ++++ xen-4.1.0-testing/tools/python/xen/xend/XendDomainInfo.py +@@ -470,6 +470,7 @@ class XendDomainInfo: + + if self._stateGet() in (XEN_API_VM_POWER_STATE_HALTED, XEN_API_VM_POWER_STATE_SUSPENDED, XEN_API_VM_POWER_STATE_CRASHED): + try: ++ self.acquire_running_lock(); + XendTask.log_progress(0, 30, self._constructDomain) + XendTask.log_progress(31, 60, self._initDomain) + +@@ -2984,6 +2985,11 @@ class XendDomainInfo: + + self._stateSet(DOM_STATE_HALTED) + self.domid = None # Do not push into _stateSet()! ++ ++ try: ++ self.release_running_lock() ++ except: ++ log.exception("Failed to release domain lock.") + finally: + self.refresh_shutdown_lock.release() + +@@ -4491,6 +4497,74 @@ class XendDomainInfo: + def has_device(self, dev_class, dev_uuid): + return (dev_uuid in self.info['%s_refs' % dev_class.lower()]) + ++ # Return name of host contained in lock file. ++ def get_lock_host(self, path): ++ fin = os.popen(xoptions.get_xend_domain_lock_utility() + \ ++ ' -s ' + path, 'r') ++ hostname = "unknown" ++ ++ try: ++ tokens = fin.readline().split() ++ for token in tokens: ++ item = token.split('=') ++ if item[0] == 'host': ++ hostname = item[1] ++ return hostname ++ finally: ++ fin.close() ++ ++ # Acquire a lock for the domain. No-op if domain locking is turned off. ++ def acquire_running_lock(self): ++ if not xoptions.get_xend_domain_lock(): ++ return ++ ++ log.debug("Acquiring lock for domain %s" % self.info['name_label']) ++ path = xoptions.get_xend_domain_lock_path() ++ path = os.path.join(path, self.get_uuid()) ++ ++ try: ++ if not os.path.exists(path): ++ mkdir.parents(path, stat.S_IRWXU) ++ except: ++ log.exception("%s could not be created." % path) ++ raise XendError("%s could not be created." % path) ++ ++ status = os.system('%s -l -p %s -n %s -i %s %s' % \ ++ (xoptions.get_xend_domain_lock_utility(), \ ++ XendNode.instance().get_name(), \ ++ self.info['name_label'], \ ++ self.info['uuid'], \ ++ path)) ++ if status != 0: ++ log.debug("Failed to aqcuire lock: status = %d" % status) ++ raise XendError("The VM is locked and appears to be running on host %s." % self.get_lock_host(path)) ++ ++ # Release lock for domain. No-op if domain locking is turned off. ++ def release_running_lock(self, name = None): ++ if not xoptions.get_xend_domain_lock(): ++ return ++ ++ dom_name = self.info['name_label'] ++ if name: ++ dom_name = name ++ log.debug("Releasing lock for domain %s" % dom_name) ++ ++ path = xoptions.get_xend_domain_lock_path() ++ path = os.path.join(path, self.get_uuid()) ++ status = os.system('%s -u -p %s -n %s -i %s %s' % \ ++ (xoptions.get_xend_domain_lock_utility(), \ ++ XendNode.instance().get_name(), \ ++ dom_name, \ ++ self.info['uuid'], \ ++ path)) ++ if status != 0: ++ log.exception("Failed to release lock: status = %s" % status) ++ try: ++ if len(os.listdir(path)) == 0: ++ shutil.rmtree(path) ++ except: ++ log.exception("Failed to remove unmanaged directory %s." % path) ++ + def __str__(self): + return '' % \ + (str(self.domid), self.info['name_label'], diff --git a/xmclone.sh b/xmclone.sh index b92211f..43acf36 100644 --- a/xmclone.sh +++ b/xmclone.sh @@ -36,6 +36,7 @@ PART=2 DOMU_IS_FILE_BASED= DOMU_ROOTDEV= FORCE=no +xm_cmd=xl # @@ -481,11 +482,11 @@ fi # # Make sure that the source VM is not running # -xmid=`xm domid "$SOURCE" 2>/dev/null` +xmid=`${xm_cmd} domid "$SOURCE" 2>/dev/null` if [ $? -eq 0 ] && [ -n "$xmid" ] && [ -z "${xmid//[[:digit:]]/}" ] then echo "domU $SOURCE is currently running on Xen, please shutdown before cloning." >&2 - echo "The command \"xm shutdown $xmid -w\" will shutdown the domU" >&2 + echo "The command \"${xm_cmd} shutdown $xmid -w\" will shutdown the domU" >&2 exit 1 fi