File b3e4401d-systemd-error-reporting.patch of Package libvirt.11695

commit b3e4401dc6203b16f4fb2c123a6f033f1747f448
Author: Daniel P. Berrange <berrange@redhat.com>
Date:   Fri Jan 16 11:26:39 2015 +0000

    systemd: don't report an error if the guest is already terminated
    
    In many cases where we invoke virSystemdTerminateMachine the
    process(es) will have already gone away on their own accord.
    In these cases we log an error message that the machine does
    not exist. We should catch this particular error and simply
    ignore it, so we don't pollute the logs.

Index: libvirt-1.2.5/src/util/virsystemd.c
===================================================================
--- libvirt-1.2.5.orig/src/util/virsystemd.c
+++ libvirt-1.2.5/src/util/virsystemd.c
@@ -274,18 +274,22 @@ int virSystemdTerminateMachine(const cha
     int ret;
     DBusConnection *conn;
     char *machinename = NULL;
+    DBusError error;
+
+    dbus_error_init(&error);
 
     ret = virDBusIsServiceEnabled("org.freedesktop.machine1");
     if (ret < 0)
-        return ret;
+        goto cleanup;
 
     if ((ret = virDBusIsServiceRegistered("org.freedesktop.systemd1")) < 0)
-        return ret;
+        goto cleanup;
+
+    ret = -1;
 
     if (!(conn = virDBusGetSystemBus()))
-        return -1;
+        goto cleanup;
 
-    ret = -1;
     if (!(machinename = virSystemdMakeMachineName(name, drivername, privileged)))
         goto cleanup;
 
@@ -302,7 +306,7 @@ int virSystemdTerminateMachine(const cha
     VIR_DEBUG("Attempting to terminate machine via systemd");
     if (virDBusCallMethod(conn,
                           NULL,
-                          NULL,
+                          &error,
                           "org.freedesktop.machine1",
                           "/org/freedesktop/machine1",
                           "org.freedesktop.machine1.Manager",
@@ -311,9 +315,16 @@ int virSystemdTerminateMachine(const cha
                           machinename) < 0)
         goto cleanup;
 
+    if (dbus_error_is_set(&error)) {
+        if (!STREQ_NULLABLE("org.freedesktop.machine1.NoSuchMachine", error.name))
+            goto cleanup;
+    }
+
     ret = 0;
 
  cleanup:
+    dbus_error_free(&error);
+
     VIR_FREE(machinename);
     return ret;
 }