Hello community,

here is the log from the commit of package hyper-v for openSUSE:Factory checked 
in at 2020-07-29 17:14:13
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Factory/hyper-v (Old)
 and      /work/SRC/openSUSE:Factory/.hyper-v.new.3592 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "hyper-v"

Wed Jul 29 17:14:13 2020 rev:42 rq:822481 version:8

Changes:
--------
--- /work/SRC/openSUSE:Factory/hyper-v/hyper-v.changes  2020-02-25 
16:02:25.048107599 +0100
+++ /work/SRC/openSUSE:Factory/.hyper-v.new.3592/hyper-v.changes        
2020-07-29 17:14:22.308254786 +0200
@@ -1,0 +2,14 @@
+Wed Jul 22 12:12:12 UTC 2020 - oher...@suse.de
+
+- Remove dependency to network-online.target now that gethostname
+  is used in kvp_daemon (bsc#1174443, bsc#1174444)
+- Reopen the devices if read() or write() returns errors (9fc3c01a)
+- Use either python2 or python3 for lsvmbus (bsc#1093910)
+- Remove sysv init scripts
+
+-------------------------------------------------------------------
+Wed Jul 22 09:12:44 UTC 2020 - Guillaume GARDET <guillaume.gar...@opensuse.org>
+
+- Enable build on aarch64
+
+-------------------------------------------------------------------

Old:
----
  hyper-v.init.fcopy.sh
  hyper-v.init.sh
  hyper-v.init.vss.sh

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ hyper-v.spec ++++++
--- /var/tmp/diff_new_pack.oIz0gG/_old  2020-07-29 17:14:27.928259131 +0200
+++ /var/tmp/diff_new_pack.oIz0gG/_new  2020-07-29 17:14:27.928259131 +0200
@@ -22,20 +22,9 @@
 %define helper_dir /usr/lib/%{name}
 
 Name:           hyper-v
-ExclusiveArch:  %ix86 x86_64
-# systemd for post 13.1 releases
-%if 0%{?suse_version} > 1310
-%define use_systemd 1
-%else
-%define use_systemd 0
-%endif
-%if %{use_systemd}
+ExclusiveArch:  %ix86 x86_64 aarch64
 %{?systemd_requires}
 BuildRequires:  pkgconfig(systemd)
-%else
-PreReq:         %insserv_prereq
-Requires(pre):  coreutils
-%endif
 # Due to usage of char device instead of netlink
 Conflicts:      kernel < 4.2
 Summary:        Microsoft Hyper-V tools
@@ -45,18 +34,15 @@
 Supplements:    modalias(pci:v00001414d00005353sv*sd*bc*sc*i*)
 Url:            http://www.kernel.org
 # Arbitrary version number
-Version:        7
+Version:        8
 Release:        0
 Source0:        hyper-v.lsvmbus.py
 Source5:        hyper-v.kvptest.ps1.txt
 Source7:        hyper-v.compare-with-upstream.sh
 Source9:        hyper-v.include.linux.hyperv.h
 Source10:       hyper-v.tools.hv.hv_kvp_daemon.c
-Source11:       hyper-v.init.sh
 Source12:       hyper-v.tools.hv.hv_vss_daemon.c
-Source13:       hyper-v.init.vss.sh
 Source14:       hyper-v.tools.hv.hv_fcopy_daemon.c
-Source15:       hyper-v.init.fcopy.sh
 Source20:       hyper-v.tools.hv.hv_get_dhcp_info.sh
 Source21:       hyper-v.tools.hv.hv_get_dns_info.sh
 Source22:       hyper-v.tools.hv.hv_set_ifconfig.sh
@@ -115,23 +101,28 @@
        -o %{hv_fcopy_daemon}
 
 %install
-%if %{use_systemd}
 # It is not a callable app anyway, so move it out of the way
 bindir=%{helper_dir}/bin
-%else
-bindir=%{_sbindir}
-%endif
 mkdir -p $RPM_BUILD_ROOT${bindir}
+mkdir -p $RPM_BUILD_ROOT%{_sbindir}
 mkdir -p $RPM_BUILD_ROOT%{helper_dir}/bin
 install -m755 %{hv_kvp_daemon} $RPM_BUILD_ROOT${bindir}
 install -m755 %{hv_vss_daemon} $RPM_BUILD_ROOT${bindir}
 install -m755 %{hv_fcopy_daemon} $RPM_BUILD_ROOT${bindir}
-install -D -m755 %{S:0} $RPM_BUILD_ROOT%{_sbindir}/lsvmbus
+sed '
+1 {
+%if 0%{?suse_version} > 1315
+s@^.*@#!%{_bindir}/python3@
+%else
+s@^.*@#!%{_bindir}/python2@
+%endif
+}
+' %{S:0} > $RPM_BUILD_ROOT%{_sbindir}/lsvmbus
+chmod 0755 $RPM_BUILD_ROOT%{_sbindir}/lsvmbus
 cp -avL %{S:20} $RPM_BUILD_ROOT%{helper_dir}/bin/hv_get_dhcp_info
 cp -avL %{S:21} $RPM_BUILD_ROOT%{helper_dir}/bin/hv_get_dns_info
 cp -avL %{S:22} $RPM_BUILD_ROOT%{helper_dir}/bin/hv_set_ifconfig
 chmod 755 $RPM_BUILD_ROOT%{helper_dir}/bin/*
-%if %{use_systemd}
 d=$RPM_BUILD_ROOT%{_unitdir}
 mkdir -vp ${d}
 #
@@ -139,9 +130,7 @@
 # started via %{_udevrulesdir}/%{hv_kvp_daemon}.rules
 [Unit]
 Description=Hyper-V KVP Daemon
-# During startup the current hostname is cached, so start very late
-Requires=network-online.target
-After=network-online.target
+After=local-fs.target
 ConditionVirtualization=microsoft
 
 [Service]
@@ -228,25 +217,12 @@
 EOF
 chmod 755 $RPM_BUILD_ROOT${bindir}/${helper}
 #
-%else
-mkdir -p $RPM_BUILD_ROOT/etc/init.d
-install -m755 %{S:11} $RPM_BUILD_ROOT/etc/init.d/%{hv_kvp_daemon}
-ln -sfvbn ../../etc/init.d/%{hv_kvp_daemon} 
$RPM_BUILD_ROOT${bindir}/rc%{hv_kvp_daemon}
-install -m755 %{S:13} $RPM_BUILD_ROOT/etc/init.d/%{hv_vss_daemon}
-ln -sfvbn ../../etc/init.d/%{hv_vss_daemon} 
$RPM_BUILD_ROOT${bindir}/rc%{hv_vss_daemon}
-install -m755 %{S:15} $RPM_BUILD_ROOT/etc/init.d/%{hv_fcopy_daemon}
-ln -sfvbn ../../etc/init.d/%{hv_fcopy_daemon} 
$RPM_BUILD_ROOT${bindir}/rc%{hv_fcopy_daemon}
-%endif
 
 %files
 %doc kvptest.ps1.txt
-%if %{use_systemd}
 %{_unitdir}
 %dir /usr/lib/udev
 %{_udevrulesdir}
-%else
-/etc/init.d/*
-%endif
 %{_sbindir}/*
 %{helper_dir}
 
@@ -269,9 +245,7 @@
        fi
        rmdir -v  /var/opt/hyperv || :
 fi
-%if %{use_systemd}
 : nothing to do in case of systemd
-%endif
 
 %post
 board_vendor=
@@ -290,33 +264,14 @@
 fi
 if test "${board_vendor}" = "Microsoft Corporation" -a "${product_name}" = 
"Virtual Machine"
 then
-%if %{use_systemd}
 : nothing to do in case of systemd
-%else
-       echo "Enabling %{hv_kvp_daemon} on '${product_name}' from 
'${board_vendor}'"
-       %{insserv_force_if_yast %{hv_kvp_daemon}}
-       echo "Enabling %{hv_vss_daemon} on '${product_name}' from 
'${board_vendor}'"
-       %{insserv_force_if_yast %{hv_vss_daemon}}
-       echo "Enabling %{hv_fcopy_daemon} on '${product_name}' from 
'${board_vendor}'"
-       %{insserv_force_if_yast %{hv_fcopy_daemon}}
-%endif
 fi
 
 %preun
-%if %{use_systemd}
 : nothing to do in case of systemd
-%else
-%stop_on_removal %{hv_kvp_daemon}
-%stop_on_removal %{hv_vss_daemon}
-%stop_on_removal %{hv_fcopy_daemon}
-%endif
 
 %postun
 # no restart on update because the daemon can not be restarted
-%if %{use_systemd}
 : nothing to do in case of systemd
-%else
-%insserv_cleanup
-%endif
 
 %changelog

++++++ hyper-v.tools.hv.hv_fcopy_daemon.c ++++++
--- /var/tmp/diff_new_pack.oIz0gG/_old  2020-07-29 17:14:28.004259190 +0200
+++ /var/tmp/diff_new_pack.oIz0gG/_new  2020-07-29 17:14:28.008259193 +0200
@@ -80,6 +80,8 @@
 
        error = 0;
 done:
+       if (error)
+               target_fname[0] = '\0';
        return error;
 }
 
@@ -108,15 +110,29 @@
        return ret;
 }
 
+/*
+ * Reset target_fname to "" in the two below functions for hibernation: if
+ * the fcopy operation is aborted by hibernation, the daemon should remove the
+ * partially-copied file; to achieve this, the hv_utils driver always fakes a
+ * CANCEL_FCOPY message upon suspend, and later when the VM resumes back,
+ * the daemon calls hv_copy_cancel() to remove the file; if a file is copied
+ * successfully before suspend, hv_copy_finished() must reset target_fname to
+ * avoid that the file can be incorrectly removed upon resume, since the faked
+ * CANCEL_FCOPY message is spurious in this case.
+ */
 static int hv_copy_finished(void)
 {
        close(target_fd);
+       target_fname[0] = '\0';
        return 0;
 }
 static int hv_copy_cancel(void)
 {
        close(target_fd);
-       unlink(target_fname);
+       if (strlen(target_fname) > 0) {
+               unlink(target_fname);
+               target_fname[0] = '\0';
+       }
        return 0;
 
 }
@@ -131,7 +147,7 @@
 
 int main(int argc, char *argv[])
 {
-       int fcopy_fd;
+       int fcopy_fd = -1;
        int error;
        int daemonize = 1, long_index = 0, opt;
        int version = FCOPY_CURRENT_VERSION;
@@ -141,7 +157,7 @@
                struct hv_do_fcopy copy;
                __u32 kernel_modver;
        } buffer = { };
-       int in_handshake = 1;
+       int in_handshake;
 
        static struct option long_options[] = {
                {"help",        no_argument,       0,  'h' },
@@ -170,6 +186,12 @@
        openlog("HV_FCOPY", 0, LOG_USER);
        syslog(LOG_INFO, "starting; pid is:%d", getpid());
 
+reopen_fcopy_fd:
+       if (fcopy_fd != -1)
+               close(fcopy_fd);
+       /* Remove any possible partially-copied file on error */
+       hv_copy_cancel();
+       in_handshake = 1;
        fcopy_fd = open("/dev/vmbus/hv_fcopy", O_RDWR);
 
        if (fcopy_fd < 0) {
@@ -196,7 +218,7 @@
                len = pread(fcopy_fd, &buffer, sizeof(buffer), 0);
                if (len < 0) {
                        syslog(LOG_ERR, "pread failed: %s", strerror(errno));
-                       exit(EXIT_FAILURE);
+                       goto reopen_fcopy_fd;
                }
 
                if (in_handshake) {
@@ -231,9 +253,14 @@
 
                }
 
+               /*
+                * pwrite() may return an error due to the faked CANCEL_FCOPY
+                * message upon hibernation. Ignore the error by resetting the
+                * dev file, i.e. closing and re-opening it.
+                */
                if (pwrite(fcopy_fd, &error, sizeof(int), 0) != sizeof(int)) {
                        syslog(LOG_ERR, "pwrite failed: %s", strerror(errno));
-                       exit(EXIT_FAILURE);
+                       goto reopen_fcopy_fd;
                }
        }
 }

++++++ hyper-v.tools.hv.hv_kvp_daemon.c ++++++
--- /var/tmp/diff_new_pack.oIz0gG/_old  2020-07-29 17:14:28.032259212 +0200
+++ /var/tmp/diff_new_pack.oIz0gG/_new  2020-07-29 17:14:28.032259212 +0200
@@ -76,7 +76,7 @@
        DNS
 };
 
-static int in_hand_shake = 1;
+static int in_hand_shake;
 
 static char *os_name = "";
 static char *os_major = "";
@@ -1361,7 +1361,7 @@
 
 int main(int argc, char *argv[])
 {
-       int kvp_fd, len;
+       int kvp_fd = -1, len;
        int error;
        struct pollfd pfd;
        char    *p;
@@ -1401,14 +1401,6 @@
        openlog("KVP", 0, LOG_USER);
        syslog(LOG_INFO, "KVP starting; pid is:%d", getpid());
 
-       kvp_fd = open("/dev/vmbus/hv_kvp", O_RDWR | O_CLOEXEC);
-
-       if (kvp_fd < 0) {
-               syslog(LOG_ERR, "open /dev/vmbus/hv_kvp failed; error: %d %s",
-                       errno, strerror(errno));
-               exit(EXIT_FAILURE);
-       }
-
        /*
         * Retrieve OS release information.
         */
@@ -1424,6 +1416,18 @@
                exit(EXIT_FAILURE);
        }
 
+reopen_kvp_fd:
+       if (kvp_fd != -1)
+               close(kvp_fd);
+       in_hand_shake = 1;
+       kvp_fd = open("/dev/vmbus/hv_kvp", O_RDWR | O_CLOEXEC);
+
+       if (kvp_fd < 0) {
+               syslog(LOG_ERR, "open /dev/vmbus/hv_kvp failed; error: %d %s",
+                      errno, strerror(errno));
+               exit(EXIT_FAILURE);
+       }
+
        /*
         * Register ourselves with the kernel.
         */
@@ -1457,9 +1461,7 @@
                if (len != sizeof(struct hv_kvp_msg)) {
                        syslog(LOG_ERR, "read failed; error:%d %s",
                               errno, strerror(errno));
-
-                       close(kvp_fd);
-                       return EXIT_FAILURE;
+                       goto reopen_kvp_fd;
                }
 
                /*
@@ -1618,13 +1620,17 @@
                        break;
                }
 
-               /* Send the value back to the kernel. */
+               /*
+                * Send the value back to the kernel. Note: the write() may
+                * return an error due to hibernation; we can ignore the error
+                * by resetting the dev file, i.e. closing and re-opening it.
+                */
 kvp_done:
                len = write(kvp_fd, hv_msg, sizeof(struct hv_kvp_msg));
                if (len != sizeof(struct hv_kvp_msg)) {
                        syslog(LOG_ERR, "write failed; error: %d %s", errno,
                               strerror(errno));
-                       exit(EXIT_FAILURE);
+                       goto reopen_kvp_fd;
                }
        }
 

++++++ hyper-v.tools.hv.hv_vss_daemon.c ++++++
--- /var/tmp/diff_new_pack.oIz0gG/_old  2020-07-29 17:14:28.056259230 +0200
+++ /var/tmp/diff_new_pack.oIz0gG/_new  2020-07-29 17:14:28.056259230 +0200
@@ -28,6 +28,8 @@
 #include <stdbool.h>
 #include <dirent.h>
 
+static bool fs_frozen;
+
 /* Don't use syslog() in the function since that can cause write to disk */
 static int vss_do_freeze(char *dir, unsigned int cmd)
 {
@@ -155,18 +157,27 @@
                        continue;
                }
                error |= vss_do_freeze(ent->mnt_dir, cmd);
-               if (error && operation == VSS_OP_FREEZE)
-                       goto err;
+               if (operation == VSS_OP_FREEZE) {
+                       if (error)
+                               goto err;
+                       fs_frozen = true;
+               }
        }
 
        endmntent(mounts);
 
        if (root_seen) {
                error |= vss_do_freeze("/", cmd);
-               if (error && operation == VSS_OP_FREEZE)
-                       goto err;
+               if (operation == VSS_OP_FREEZE) {
+                       if (error)
+                               goto err;
+                       fs_frozen = true;
+               }
        }
 
+       if (operation == VSS_OP_THAW && !error)
+               fs_frozen = false;
+
        goto out;
 err:
        save_errno = errno;
@@ -175,6 +186,7 @@
                endmntent(mounts);
        }
        vss_operate(VSS_OP_THAW);
+       fs_frozen = false;
        /* Call syslog after we thaw all filesystems */
        if (ent)
                syslog(LOG_ERR, "FREEZE of %s failed; error:%d %s",
@@ -196,13 +208,13 @@
 
 int main(int argc, char *argv[])
 {
-       int vss_fd, len;
+       int vss_fd = -1, len;
        int error;
        struct pollfd pfd;
        int     op;
        struct hv_vss_msg vss_msg[1];
        int daemonize = 1, long_index = 0, opt;
-       int in_handshake = 1;
+       int in_handshake;
        __u32 kernel_modver;
 
        static struct option long_options[] = {
@@ -232,6 +244,18 @@
        openlog("Hyper-V VSS", 0, LOG_USER);
        syslog(LOG_INFO, "VSS starting; pid is:%d", getpid());
 
+reopen_vss_fd:
+       if (vss_fd != -1)
+               close(vss_fd);
+       if (fs_frozen) {
+               if (vss_operate(VSS_OP_THAW) || fs_frozen) {
+                       syslog(LOG_ERR, "failed to thaw file system: err=%d",
+                              errno);
+                       exit(EXIT_FAILURE);
+               }
+       }
+
+       in_handshake = 1;
        vss_fd = open("/dev/vmbus/hv_vss", O_RDWR);
        if (vss_fd < 0) {
                syslog(LOG_ERR, "open /dev/vmbus/hv_vss failed; error: %d %s",
@@ -284,8 +308,7 @@
                if (len != sizeof(struct hv_vss_msg)) {
                        syslog(LOG_ERR, "read failed; error:%d %s",
                               errno, strerror(errno));
-                       close(vss_fd);
-                       return EXIT_FAILURE;
+                       goto reopen_vss_fd;
                }
 
                op = vss_msg->vss_hdr.operation;
@@ -312,14 +335,18 @@
                default:
                        syslog(LOG_ERR, "Illegal op:%d\n", op);
                }
+
+               /*
+                * The write() may return an error due to the faked VSS_OP_THAW
+                * message upon hibernation. Ignore the error by resetting the
+                * dev file, i.e. closing and re-opening it.
+                */
                vss_msg->error = error;
                len = write(vss_fd, vss_msg, sizeof(struct hv_vss_msg));
                if (len != sizeof(struct hv_vss_msg)) {
                        syslog(LOG_ERR, "write failed; error: %d %s", errno,
                               strerror(errno));
-
-                       if (op == VSS_OP_FREEZE)
-                               vss_operate(VSS_OP_THAW);
+                       goto reopen_vss_fd;
                }
        }
 


Reply via email to