]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/commitdiff
qemu: Remove need for qemuDomainParseIOThreadAlias
authorJohn Ferlan <jferlan@redhat.com>
Mon, 27 Apr 2015 18:16:54 +0000 (14:16 -0400)
committerJohn Ferlan <jferlan@redhat.com>
Tue, 28 Apr 2015 10:33:30 +0000 (06:33 -0400)
Rather than have a separate routine to parse the alias of an iothread
returned from qemu in order to get the iothread_id value, parse the alias
when returning and just return the iothread_id in qemuMonitorIOThreadInfoPtr

This set of patches removes the function, changes the "char *name" to
"unsigned int" and handles all the fallout.

src/qemu/qemu_command.c
src/qemu/qemu_command.h
src/qemu/qemu_driver.c
src/qemu/qemu_monitor.c
src/qemu/qemu_monitor.h
src/qemu/qemu_monitor_json.c
src/qemu/qemu_process.c
tests/qemumonitorjsontest.c

index 247954fe2b9f8dedbf69f517c1a8d9441d60c71b..ba15dc9f1132f22662b2900cc6c48e97529ab30d 100644 (file)
@@ -677,23 +677,6 @@ qemuOpenVhostNet(virDomainDefPtr def,
     return -1;
 }
 
-int
-qemuDomainParseIOThreadAlias(char *alias,
-                             unsigned int *iothread_id)
-{
-    unsigned int idval;
-
-    if (virStrToLong_ui(alias + strlen("iothread"),
-                        NULL, 10, &idval) < 0) {
-        virReportError(VIR_ERR_INTERNAL_ERROR,
-                       _("failed to find iothread id for '%s'"),
-                       alias);
-        return -1;
-    }
-
-    *iothread_id = idval;
-    return 0;
-}
 
 int
 qemuNetworkPrepareDevices(virDomainDefPtr def)
index 538ccdf550a639cd5e301b7f0f69f9b94112d9e3..a29db41d1ec5504199cc7f332f25bb991af3143e 100644 (file)
@@ -238,9 +238,6 @@ int qemuOpenVhostNet(virDomainDefPtr def,
                      int *vhostfd,
                      size_t *vhostfdSize);
 
-int qemuDomainParseIOThreadAlias(char *alias,
-                                 unsigned int *iothread_id);
-
 int qemuNetworkPrepareDevices(virDomainDefPtr def);
 
 /*
index 74dcb0a53dd4f44fce65306d2f88bfed47a0e5a5..d0147e96031cdd5d2f2032ecb22f1f7f065ade21 100644 (file)
@@ -5918,16 +5918,11 @@ qemuDomainGetIOThreadsLive(virQEMUDriverPtr driver,
         goto endjob;
 
     for (i = 0; i < niothreads; i++) {
-        unsigned int iothread_id;
         virBitmapPtr map = NULL;
 
-        if (qemuDomainParseIOThreadAlias(iothreads[i]->name,
-                                         &iothread_id) < 0)
-            goto endjob;
-
         if (VIR_ALLOC(info_ret[i]) < 0)
             goto endjob;
-        info_ret[i]->iothread_id = iothread_id;
+        info_ret[i]->iothread_id = iothreads[i]->iothread_id;
 
         if (virProcessGetAffinity(iothreads[i]->thread_id, &map, hostcpus) < 0)
             goto endjob;
@@ -6292,7 +6287,7 @@ qemuDomainHotplugAddIOThread(virQEMUDriverPtr driver,
      * in the QEMU IOThread list, so we can add it to our iothreadids list
      */
     for (idx = 0; idx < new_niothreads; idx++) {
-        if (STREQ(new_iothreads[idx]->name, alias))
+        if (new_iothreads[idx]->iothread_id == iothread_id)
             break;
     }
 
index 1e7d2efb978c8194c06d9fb3546b37d8886bf626..48bfeb0956222f7e2a40acea6850d1f4765b169e 100644 (file)
@@ -3818,7 +3818,6 @@ qemuMonitorIOThreadInfoFree(qemuMonitorIOThreadInfoPtr iothread)
 {
     if (!iothread)
         return;
-    VIR_FREE(iothread->name);
     VIR_FREE(iothread);
 }
 
index cd4cc6634f866da8c9b382325a4a58594cfa70e4..bce8031f4cc4f9c7a0c5b38aba11f65e48d8a837 100644 (file)
@@ -877,7 +877,7 @@ typedef struct _qemuMonitorIOThreadInfo qemuMonitorIOThreadInfo;
 typedef qemuMonitorIOThreadInfo *qemuMonitorIOThreadInfoPtr;
 
 struct _qemuMonitorIOThreadInfo {
-    char *name;
+    unsigned int iothread_id;
     int thread_id;
 };
 int qemuMonitorGetIOThreads(qemuMonitorPtr mon,
index 3af319c931d40252cb7b6272bab927c99c0556bd..c02ef47d2d689d132daee0ef730c569d9cff80a6 100644 (file)
@@ -6481,20 +6481,28 @@ qemuMonitorJSONGetIOThreads(qemuMonitorPtr mon,
         const char *tmp;
         qemuMonitorIOThreadInfoPtr info;
 
-        if (VIR_ALLOC(info) < 0)
-            goto cleanup;
-
-        infolist[i] = info;
-
         if (!(tmp = virJSONValueObjectGetString(child, "id"))) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
                            _("query-iothreads reply data was missing 'id'"));
             goto cleanup;
         }
 
-        if (VIR_STRDUP(info->name, tmp) < 0)
+        if (!STRPREFIX(tmp, "iothread"))
+            continue;
+
+        if (VIR_ALLOC(info) < 0)
             goto cleanup;
 
+        infolist[i] = info;
+
+        if (virStrToLong_ui(tmp + strlen("iothread"),
+                            NULL, 10, &info->iothread_id) < 0) {
+            virReportError(VIR_ERR_INTERNAL_ERROR,
+                           _("failed to find iothread id for '%s'"),
+                           tmp);
+            goto cleanup;
+        }
+
         if (virJSONValueObjectGetNumberInt(child, "thread-id",
                                            &info->thread_id) < 0) {
             virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
index 5ae2241f894b4ddbdb6a56254fd77bc35e3a8ad9..f06ec5688cde54d1367218d164af506af817181c 100644 (file)
@@ -2248,16 +2248,13 @@ qemuProcessDetectIOThreadPIDs(virQEMUDriverPtr driver,
     }
 
     for (i = 0; i < niothreads; i++) {
-        unsigned int iothread_id;
         virDomainIOThreadIDDefPtr iothrid;
 
-        if (qemuDomainParseIOThreadAlias(iothreads[i]->name,
-                                         &iothread_id) < 0)
-            goto cleanup;
-
-        if (!(iothrid = virDomainIOThreadIDFind(vm->def, iothread_id))) {
+        if (!(iothrid = virDomainIOThreadIDFind(vm->def,
+                                                iothreads[i]->iothread_id))) {
             virReportError(VIR_ERR_INTERNAL_ERROR,
-                           _("iothread %d not found"), iothread_id);
+                           _("iothread %d not found"),
+                           iothreads[i]->iothread_id);
             goto cleanup;
         }
         iothrid->thread_id = iothreads[i]->thread_id;
index f729c7c9d8e5a8a6bab77a63651223a4124e2f04..39eeaa7bfb151c08804e5c9699819f516ff8cb9d 100644 (file)
@@ -2269,12 +2269,12 @@ testQemuMonitorJSONGetIOThreads(const void *data)
         goto cleanup;
     }
 
-#define CHECK(i, wantname, wantthread_id)                               \
+#define CHECK(i, wantiothread_id, wantthread_id)                        \
     do {                                                                \
-        if (STRNEQ(info[i]->name, (wantname))) {                        \
+        if (info[i]->iothread_id != (wantiothread_id)) {                \
             virReportError(VIR_ERR_INTERNAL_ERROR,                      \
-                           "name %s is not %s",                         \
-                           info[i]->name, (wantname));                  \
+                           "iothread_id %u is not %u",                  \
+                           info[i]->iothread_id, (wantiothread_id));    \
             goto cleanup;                                               \
         }                                                               \
         if (info[i]->thread_id != (wantthread_id)) {                    \
@@ -2285,8 +2285,8 @@ testQemuMonitorJSONGetIOThreads(const void *data)
         }                                                               \
     } while (0)
 
-    CHECK(0, "iothread1", 30992);
-    CHECK(1, "iothread2", 30993);
+    CHECK(0, 1, 30992);
+    CHECK(1, 2, 30993);
 
 #undef CHECK