<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">From 0b6bf6597e2ea411433bc5e0bf4a16fb864e1e9a Mon Sep 17 00:00:00 2001
Message-Id: &lt;0b6bf6597e2ea411433bc5e0bf4a16fb864e1e9a.1367947969.git.minovotn@redhat.com&gt;
In-Reply-To: &lt;707b9b97153063374d2530e72c49b1499fc21af9.1367947969.git.minovotn@redhat.com&gt;
References: &lt;707b9b97153063374d2530e72c49b1499fc21af9.1367947969.git.minovotn@redhat.com&gt;
From: Michal Novotny &lt;minovotn@redhat.com&gt;
Date: Tue, 7 May 2013 18:36:39 +0200
Subject: [PATCH 016/114] Revert "qga: implement qmp_guest_get_vcpus() for
 Linux with sysfs"

This reverts commit 6e2c6cdc12232f9e7487ccb674d52339252774d6.

Reverting as asked by Laszlo in message &lt;51892739.2030807@redhat.com&gt;
because of the ordering issue (most likely) related to supersed
testing.

Signed-off-by: Michal Novotny &lt;minovotn@redhat.com&gt;
---
 qga/commands-posix.c | 146 +++------------------------------------------------
 1 file changed, 6 insertions(+), 140 deletions(-)

diff --git a/qga/commands-posix.c b/qga/commands-posix.c
index 2045bef..614f5c1 100644
--- a/qga/commands-posix.c
+++ b/qga/commands-posix.c
@@ -32,10 +32,6 @@
 #include &lt;sys/socket.h&gt;
 #include &lt;net/if.h&gt;
 #include &lt;sys/wait.h&gt;
-#include &lt;unistd.h&gt;
-#include &lt;errno.h&gt;
-#include &lt;fcntl.h&gt;
-#include &lt;inttypes.h&gt;
 #include "qga/guest-agent-core.h"
 #include "qga-qmp-commands.h"
 #include "qerror.h"
@@ -1114,136 +1110,6 @@ error:
     return NULL;
 }
 
-#define SYSCONF_EXACT(name, err) sysconf_exact((name), #name, (err))
-
-static long sysconf_exact(int name, const char *name_str, Error **err)
-{
-    long ret;
-
-    errno = 0;
-    ret = sysconf(name);
-    if (ret == -1) {
-        if (errno == 0) {
-            error_setg(err, "sysconf(%s): value indefinite", name_str);
-        } else {
-            error_setg_errno(err, errno, "sysconf(%s)", name_str);
-        }
-    }
-    return ret;
-}
-
-/* Transfer online/offline status between @vcpu and the guest system.
- *
- * On input either @errp or *@errp must be NULL.
- *
- * In system-to-@vcpu direction, the following @vcpu fields are accessed:
- * - R: vcpu-&gt;logical_id
- * - W: vcpu-&gt;online
- * - W: vcpu-&gt;can_offline
- *
- * In @vcpu-to-system direction, the following @vcpu fields are accessed:
- * - R: vcpu-&gt;logical_id
- * - R: vcpu-&gt;online
- *
- * Written members remain unmodified on error.
- */
-static void transfer_vcpu(GuestLogicalProcessor *vcpu, bool sys2vcpu,
-                          Error **errp)
-{
-    char *dirpath;
-    int dirfd;
-
-    dirpath = g_strdup_printf("/sys/devices/system/cpu/cpu%" PRId64 "/",
-                              vcpu-&gt;logical_id);
-    dirfd = open(dirpath, O_RDONLY | O_DIRECTORY);
-    if (dirfd == -1) {
-        error_setg_errno(errp, errno, "open(\"%s\")", dirpath);
-    } else {
-        static const char fn[] = "online";
-        int fd;
-        int res;
-
-        fd = openat(dirfd, fn, sys2vcpu ? O_RDONLY : O_RDWR);
-        if (fd == -1) {
-            if (errno != ENOENT) {
-                error_setg_errno(errp, errno, "open(\"%s/%s\")", dirpath, fn);
-            } else if (sys2vcpu) {
-                vcpu-&gt;online = true;
-                vcpu-&gt;can_offline = false;
-            } else if (!vcpu-&gt;online) {
-                error_setg(errp, "logical processor #%" PRId64 " can't be "
-                           "offlined", vcpu-&gt;logical_id);
-            } /* otherwise pretend successful re-onlining */
-        } else {
-            unsigned char status;
-
-            res = pread(fd, &amp;status, 1, 0);
-            if (res == -1) {
-                error_setg_errno(errp, errno, "pread(\"%s/%s\")", dirpath, fn);
-            } else if (res == 0) {
-                error_setg(errp, "pread(\"%s/%s\"): unexpected EOF", dirpath,
-                           fn);
-            } else if (sys2vcpu) {
-                vcpu-&gt;online = (status != '0');
-                vcpu-&gt;can_offline = true;
-            } else if (vcpu-&gt;online != (status != '0')) {
-                status = '0' + vcpu-&gt;online;
-                if (pwrite(fd, &amp;status, 1, 0) == -1) {
-                    error_setg_errno(errp, errno, "pwrite(\"%s/%s\")", dirpath,
-                                     fn);
-                }
-            } /* otherwise pretend successful re-(on|off)-lining */
-
-            res = close(fd);
-            g_assert(res == 0);
-        }
-
-        res = close(dirfd);
-        g_assert(res == 0);
-    }
-
-    g_free(dirpath);
-}
-
-GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)
-{
-    int64_t current;
-    GuestLogicalProcessorList *head, **link;
-    long sc_max;
-    Error *local_err = NULL;
-
-    current = 0;
-    head = NULL;
-    link = &amp;head;
-    sc_max = SYSCONF_EXACT(_SC_NPROCESSORS_CONF, &amp;local_err);
-
-    while (local_err == NULL &amp;&amp; current &lt; sc_max) {
-        GuestLogicalProcessor *vcpu;
-        GuestLogicalProcessorList *entry;
-
-        vcpu = g_malloc0(sizeof *vcpu);
-        vcpu-&gt;logical_id = current++;
-        vcpu-&gt;has_can_offline = true; /* lolspeak ftw */
-        transfer_vcpu(vcpu, true, &amp;local_err);
-
-        entry = g_malloc0(sizeof *entry);
-        entry-&gt;value = vcpu;
-
-        *link = entry;
-        link = &amp;entry-&gt;next;
-    }
-
-    if (local_err == NULL) {
-        /* there's no guest with zero VCPUs */
-        g_assert(head != NULL);
-        return head;
-    }
-
-    qapi_free_GuestLogicalProcessorList(head);
-    error_propagate(errp, local_err);
-    return NULL;
-}
-
 #else /* defined(__linux__) */
 
 void qmp_guest_suspend_disk(Error **err)
@@ -1267,12 +1133,6 @@ GuestNetworkInterfaceList *qmp_guest_network_get_interfaces(Error **errp)
     return NULL;
 }
 
-GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)
-{
-    error_set(errp, QERR_UNSUPPORTED);
-    return NULL;
-}
-
 #endif
 
 #if !defined(CONFIG_FSFREEZE)
@@ -1306,6 +1166,12 @@ void qmp_guest_fstrim(bool has_minimum, int64_t minimum, Error **err)
 }
 #endif
 
+GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp)
+{
+    error_set(errp, QERR_UNSUPPORTED);
+    return NULL;
+}
+
 int64_t qmp_guest_set_vcpus(GuestLogicalProcessorList *vcpus, Error **errp)
 {
     error_set(errp, QERR_UNSUPPORTED);
-- 
1.7.11.7

</pre></body></html>