From 86d02750bf9d4f554c792063e18fefb91c22e1cb Mon Sep 17 00:00:00 2001
From: Andrey Gordeev <dreyou@gmail.com>
Date: Tue, 24 Jul 2012 15:09:49 +0400
Subject: [PATCH 1/4] CentOS 6.3 changes

---
 build-aux/release.sh        |   11 +++++++++--
 vdsm.spec.in                |   11 +++++++----
 vdsm/vdsm-logrotate.conf.in |    1 -
 vdsm/vdsmd.init.in          |    3 ++-
 vdsm_reg/deployUtil.py.in   |    3 ++-
 5 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/build-aux/release.sh b/build-aux/release.sh
index 2c8a6b1..9f6bd7f 100755
--- a/build-aux/release.sh
+++ b/build-aux/release.sh
@@ -12,5 +12,12 @@ AWK_RELEASE='
       else if (NF == 3) print 0, $2, "git" substr($3, 2)
       else if (NF == 4) print $2, $3, "git" substr($4, 2)
     }'
-git describe --match="v[0-9]*" 2> /dev/null \
-    | awk "$AWK_RELEASE" | tr -cd '[:alnum:].'
+#git describe --match="v[0-9]*" 2> /dev/null \
+#    | awk "$AWK_RELEASE" | tr -cd '[:alnum:].'
+if [ $LOCAL_BUILDID ]; then
+   git describe --match="v[0-9]*" 2> /dev/null \
+       | awk "$AWK_RELEASE" | sed "s/git.*$/{$LOCAL_BUILDID}/" | tr -cd '[:alnum:].'
+else
+   git describe --match="v[0-9]*" 2> /dev/null \
+       | awk "$AWK_RELEASE" | tr -cd '[:alnum:].'
+fi
diff --git a/vdsm.spec.in b/vdsm.spec.in
index 6be7da4..8fb37b0 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -40,7 +40,6 @@ BuildRequires: systemd-units
 
 Requires: which
 Requires: sudo >= 1.7.3
-Requires: logrotate >= 3.8.0
 Requires: xz
 Requires: ntp
 Requires: python-ethtool
@@ -49,16 +48,18 @@ Requires: lvm2 >= 2.02.95
 Requires: sanlock >= 2.1, sanlock-python
 
 %if 0%{?rhel}
+Requires: logrotate >= 3.7.0
 Requires: python
 # Update the qemu-kvm requires when block_stream will be included
 Requires: qemu-kvm >= 2:0.12.1.2-2.227
 Requires: qemu-img >= 2:0.12.1.2-2.227
-Requires: libvirt >= 0.9.10-20
+Requires: libvirt >= 0.9.10-21
 Requires: libvirt-python, libvirt-lock-sanlock
 Requires: iscsi-initiator-utils >= 6.2.0.872-15
 Requires: device-mapper-multipath >= 0.4.9-52
 Requires: e2fsprogs >= 1.41.12-11
 %else
+Requires: logrotate >= 3.8.0
 # Subprocess and thread bug was found on python 2.7.2
 Requires: python >= 2.7.3
 Requires: qemu-kvm >= 2:0.15.0-4
@@ -342,6 +343,8 @@ install -Dm 0644 vdsm/limits.conf \
 # Install the SysV init scripts
 install -Dm 0755 vdsm/vdsmd.init %{buildroot}%{_initrddir}/vdsmd
 install -Dm 0755 vdsm_reg/vdsm-reg.init %{buildroot}%{_initrddir}/vdsm-reg
+install -Dm 0644 vdsm/vdsm.conf.sample \
+                 %{buildroot}%{_sysconfdir}/vdsm/vdsm.conf
 
 # This is not commonplace, but we want /var/log/core to be a world-writable
 # dropbox for core dumps
@@ -669,9 +672,9 @@ exit 0
 %files python
 %defattr(-, root, root, -)
 %{_bindir}/vdsm-tool
-%if !0%{?rhel}
+#%if !0%{?rhel}
 %config(noreplace) %{_sysconfdir}/%{vdsm_name}/vdsm.conf
-%endif
+#%endif
 %{python_sitelib}/%{vdsm_name}/__init__.py*
 %{python_sitelib}/%{vdsm_name}/config.py*
 %{python_sitelib}/%{vdsm_name}/constants.py*
diff --git a/vdsm/vdsm-logrotate.conf.in b/vdsm/vdsm-logrotate.conf.in
index ce71015..bced1b4 100644
--- a/vdsm/vdsm-logrotate.conf.in
+++ b/vdsm/vdsm-logrotate.conf.in
@@ -15,5 +15,4 @@
     compresscmd /usr/bin/xz
     uncompresscmd /usr/bin/unxz
     compressext .xz
-    su @VDSMUSER@ @VDSMGROUP@
 }
diff --git a/vdsm/vdsmd.init.in b/vdsm/vdsmd.init.in
index dd6f3c6..5dd2e47 100755
--- a/vdsm/vdsmd.init.in
+++ b/vdsm/vdsmd.init.in
@@ -147,7 +147,8 @@ shutdown_conflicting_srv() {
 }
 
 upstart_libvirt() {
-    [[ -x /sbin/initctl ]]
+#    [[ -x /sbin/initctl ]]
+    [[ -x /sbin/foo ]]
 }
 
 start_needed_srv() {
diff --git a/vdsm_reg/deployUtil.py.in b/vdsm_reg/deployUtil.py.in
index 6bd4b3d..7dc049e 100644
--- a/vdsm_reg/deployUtil.py.in
+++ b/vdsm_reg/deployUtil.py.in
@@ -1046,7 +1046,8 @@ def yumSearchVersion(pkgName, ver):
     import rpmUtils.miscutils
 
     for pkg in yumListPackages(pkgName):
-        if rpmUtils.miscutils.compareVerOnly(pkg.ver, ver) >= 0:
+#        if rpmUtils.miscutils.compareVerOnly(pkg.ver, ver) >= 0:
+        if rpmUtils.miscutils.compareEVR(('', pkg.ver, ''), ('', ver, '')) >= 0:
             return True
     else:
         return False
-- 
1.7.1


From fc1cd18dee6c29c8d7106444a2c70c682205fb42 Mon Sep 17 00:00:00 2001
From: Andrey Gordeev <dreyou@gmail.com>
Date: Fri, 24 Aug 2012 13:47:10 +0400
Subject: [PATCH 2/4] Add usbutils req to usbhook

---
 vdsm.spec.in |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/vdsm.spec.in b/vdsm.spec.in
index 8fb37b0..096088c 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -207,6 +207,7 @@ Allow adding floppy to VM
 %package hook-hostusb
 Summary:        Allow attaching USB device from host
 BuildArch:      noarch
+Requires:       usbutils
 
 %description hook-hostusb
 Hook is getting vendor and product id of USB device
-- 
1.7.1


From 9cd912e70d0e35ede4a7616aee566cb541e3f30a Mon Sep 17 00:00:00 2001
From: Andrey Gordeev <dreyou@gmail.com>
Date: Mon, 27 Aug 2012 18:27:09 +0400
Subject: [PATCH 3/4] Softdog load

---
 vdsm.spec.in |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/vdsm.spec.in b/vdsm.spec.in
index 096088c..2e0541e 100644
--- a/vdsm.spec.in
+++ b/vdsm.spec.in
@@ -398,6 +398,15 @@ if /usr/sbin/selinuxenabled; then
 fi
 
 %post
+if [ -f /etc/sysconfig/modules/softdog.modules ]
+then
+    cp /etc/sysconfig/modules/softdog.modules /etc/vdsm/softdog.modules.prevdsm
+fi
+echo -e '#!/bin/sh\nmodprobe softdog\nexit 0' > /etc/sysconfig/modules/softdog.modules
+chmod +x /etc/sysconfig/modules/softdog.modules
+/sbin/chkconfig wdmd on
+/sbin/chkconfig sanlock on
+
 # update the vdsm "secret" password for libvirt
 if [ -f /etc/pki/vdsm/keys/libvirt_password ]; then
     /usr/sbin/saslpasswd2 -p -a libvirt vdsm@rhevh < \
@@ -464,6 +473,12 @@ exit 0
 %endif
 
 %postun
+if [ -f /etc/vdsm/softdog.modules.prevdsm ]
+then
+    cp -f  /etc/vdsm/softdog.modules.prevdsm /etc/sysconfig/modules/softdog.modules
+else
+    rm -f /etc/sysconfig/modules/softdog.module
+fi
 %if 0%{?rhel}
 if [ "$1" -ge 1 ]; then
     /sbin/service vdsmd condrestart > /dev/null 2>&1
-- 
1.7.1


From 4a9875b8d8cc6abd442db1119467751651114e1b Mon Sep 17 00:00:00 2001
From: Andrey Gordeev <dreyou@gmail.com>
Date: Wed, 23 Jan 2013 11:29:51 +0400
Subject: [PATCH 4/4] Minor changes

---
 vdsm/caps.py |   18 +++++++++++++++++-
 1 files changed, 17 insertions(+), 1 deletions(-)

diff --git a/vdsm/caps.py b/vdsm/caps.py
index 5c9fa78..a2d205e 100644
--- a/vdsm/caps.py
+++ b/vdsm/caps.py
@@ -280,9 +280,25 @@ def _getKeyPackages():
                         'vdsm', 'spice-server', 'libvirt']
 
         try:
+#            for pkg in KEY_PACKAGES:
+#                rc, out, err = utils.execCmd([constants.EXT_RPM, '-q', '--qf',
+#                      '%{NAME}\t%{VERSION}\t%{RELEASE}\t%{BUILDTIME}\n', pkg],
+#                      sudo=False)
+            import rpm
+
+            ts = rpm.TransactionSet()
+
+            QEMU_RHEV = False
+            if len(list(ts.dbMatch('name', 'qemu-kvm-rhev'))) != 0:
+                QEMU_RHEV = True
+
             for pkg in KEY_PACKAGES:
+                if (pkg == 'qemu-kvm' or pkg == 'qemu-img') and QEMU_RHEV:
+                    rpkg = pkg + '-rhev'
+                else:
+                    rpkg = pkg
                 rc, out, err = utils.execCmd([constants.EXT_RPM, '-q', '--qf',
-                      '%{NAME}\t%{VERSION}\t%{RELEASE}\t%{BUILDTIME}\n', pkg],
+                      '%{NAME}\t%{VERSION}\t%{RELEASE}\t%{BUILDTIME}\n', rpkg],
                       sudo=False)
                 if rc: continue
                 line = out[-1]
-- 
1.7.1

