[PATCH] qemu: agent: remove all code around disabled DEBUG_IO/DEBUG_RAW_IO definitions

Ani Sinha posted 1 patch 2 years, 3 months ago
Test syntax-check failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20220104121743.46949-1-ani@anisinha.ca
src/qemu/qemu_agent.c        | 51 ------------------------------------
src/qemu/qemu_monitor_json.c |  4 ---
2 files changed, 55 deletions(-)
[PATCH] qemu: agent: remove all code around disabled DEBUG_IO/DEBUG_RAW_IO definitions
Posted by Ani Sinha 2 years, 3 months ago
DEBUG_IO and DEBUG_RAW_IO are disabled and hence the code #defined under them
are useless. Remove them. Also remove similar useless code from
qemu_monitor_json.

See also 4aae00bf1287f ("qemu: monitor: Remove disabled debug infrastructure")

Signed-off-by: Ani Sinha <ani@anisinha.ca>
---
 src/qemu/qemu_agent.c        | 51 ------------------------------------
 src/qemu/qemu_monitor_json.c |  4 ---
 2 files changed, 55 deletions(-)

diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c
index cb3bf97415..f33cd47078 100644
--- a/src/qemu/qemu_agent.c
+++ b/src/qemu/qemu_agent.c
@@ -48,9 +48,6 @@ VIR_LOG_INIT("qemu.qemu_agent");
 
 #define LINE_ENDING "\n"
 
-#define DEBUG_IO 0
-#define DEBUG_RAW_IO 0
-
 /* We read from QEMU until seeing a \r\n pair to indicate a
  * completed reply or event. To avoid memory denial-of-service
  * though, we must have a size limit on amount of data we
@@ -137,25 +134,6 @@ static int qemuAgentOnceInit(void)
 VIR_ONCE_GLOBAL_INIT(qemuAgent);
 
 
-#if DEBUG_RAW_IO
-static char *
-qemuAgentEscapeNonPrintable(const char *text)
-{
-    size_t i;
-    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
-    for (i = 0; text[i] != '\0'; i++) {
-        if (text[i] == '\\')
-            virBufferAddLit(&buf, "\\\\");
-        else if (g_ascii_isprint(text[i]) || text[i] == '\n' ||
-                 (text[i] == '\r' && text[i+1] == '\n'))
-            virBufferAddChar(&buf, text[i]);
-        else
-            virBufferAsprintf(&buf, "\\x%02x", text[i]);
-    }
-    return virBufferContentAndReset(&buf);
-}
-#endif
-
 
 static void qemuAgentDispose(void *obj)
 {
@@ -300,14 +278,6 @@ static int qemuAgentIOProcessData(qemuAgent *agent,
 {
     int used = 0;
     size_t i = 0;
-#if DEBUG_IO
-# if DEBUG_RAW_IO
-    g_autofree char *str1 = qemuAgentEscapeNonPrintable(data);
-    VIR_ERROR(_("[%s]"), str1);
-# else
-    VIR_DEBUG("Data %zu bytes [%s]", len, data);
-# endif
-#endif
 
     while (used < len) {
         char *nl = strstr(data + used, LINE_ENDING);
@@ -344,17 +314,6 @@ qemuAgentIOProcess(qemuAgent *agent)
     if (agent->msg && agent->msg->txOffset == agent->msg->txLength)
         msg = agent->msg;
 
-#if DEBUG_IO
-# if DEBUG_RAW_IO
-    g_autofree char *str1 = qemuAgentEscapeNonPrintable(msg ? msg->txBuffer : "");
-    g_autofree char *str2 = qemuAgentEscapeNonPrintable(agent->buffer);
-    VIR_ERROR(_("Process %zu %p %p [[[%s]]][[[%s]]]"),
-              agent->bufferOffset, agent->msg, msg, str1, str2);
-# else
-    VIR_DEBUG("Process %zu", agent->bufferOffset);
-# endif
-#endif
-
     len = qemuAgentIOProcessData(agent,
                                  agent->buffer, agent->bufferOffset,
                                  msg);
@@ -369,9 +328,6 @@ qemuAgentIOProcess(qemuAgent *agent)
         VIR_FREE(agent->buffer);
         agent->bufferOffset = agent->bufferLength = 0;
     }
-#if DEBUG_IO
-    VIR_DEBUG("Process done %zu used %d", agent->bufferOffset, len);
-#endif
     if (msg && msg->finished)
         virCondBroadcast(&agent->notify);
     return len;
@@ -455,10 +411,6 @@ qemuAgentIORead(qemuAgent *agent)
         agent->buffer[agent->bufferOffset] = '\0';
     }
 
-#if DEBUG_IO
-    VIR_DEBUG("Now read %zu bytes of data", agent->bufferOffset);
-#endif
-
     return ret;
 }
 
@@ -527,9 +479,6 @@ qemuAgentIO(GSocket *socket G_GNUC_UNUSED,
     virObjectRef(agent);
     /* lock access to the agent and protect fd */
     virObjectLock(agent);
-#if DEBUG_IO
-    VIR_DEBUG("Agent %p I/O on watch %d socket %p cond %d", agent, agent->socket, cond);
-#endif
 
     if (agent->fd == -1 || !agent->watch) {
         virObjectUnlock(agent);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index e45b43eb5a..0f1999f413 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -280,10 +280,6 @@ int qemuMonitorJSONIOProcess(qemuMonitor *mon,
         }
     }
 
-#if DEBUG_IO
-    VIR_DEBUG("Total used %d bytes out of %zd available in buffer", used, len);
-#endif
-
     return used;
 }
 
-- 
2.25.1

Re: [PATCH] qemu: agent: remove all code around disabled DEBUG_IO/DEBUG_RAW_IO definitions
Posted by Peter Krempa 2 years, 3 months ago
On Tue, Jan 04, 2022 at 17:47:43 +0530, Ani Sinha wrote:
> DEBUG_IO and DEBUG_RAW_IO are disabled and hence the code #defined under them
> are useless. Remove them. Also remove similar useless code from
> qemu_monitor_json.
> 
> See also 4aae00bf1287f ("qemu: monitor: Remove disabled debug infrastructure")

~/libvirt $ git show 4aae00bf1287f
fatal: ambiguous argument '4aae00bf1287f': unknown revision or path not in the working tree.

Which is expected as I didn't yet push the commit you are refering to.
I'll drop it along with the last sentence of the previous paragraph
before pushing.

> 
> Signed-off-by: Ani Sinha <ani@anisinha.ca>
> ---
>  src/qemu/qemu_agent.c        | 51 ------------------------------------
>  src/qemu/qemu_monitor_json.c |  4 ---
>  2 files changed, 55 deletions(-)

Reviewed-by: Peter Krempa <pkrempa@redhat.com>

Re: [PATCH] qemu: agent: remove all code around disabled DEBUG_IO/DEBUG_RAW_IO definitions
Posted by Ani Sinha 2 years, 3 months ago

On Thu, 6 Jan 2022, Peter Krempa wrote:

> On Tue, Jan 04, 2022 at 17:47:43 +0530, Ani Sinha wrote:
> > DEBUG_IO and DEBUG_RAW_IO are disabled and hence the code #defined under them
> > are useless. Remove them. Also remove similar useless code from
> > qemu_monitor_json.
> >
> > See also 4aae00bf1287f ("qemu: monitor: Remove disabled debug infrastructure")
>
> ~/libvirt $ git show 4aae00bf1287f
> fatal: ambiguous argument '4aae00bf1287f': unknown revision or path not in the working tree.
>
> Which is expected as I didn't yet push the commit you are refering to.

Right but I had applied your commit to my tree and I think the hash would
be the same. I just assumed you would push your commit first and then push
mine and adjust the hash appropriately (if needed at all).

> I'll drop it along with the last sentence of the previous paragraph
> before pushing.
>
> >
> > Signed-off-by: Ani Sinha <ani@anisinha.ca>
> > ---
> >  src/qemu/qemu_agent.c        | 51 ------------------------------------
> >  src/qemu/qemu_monitor_json.c |  4 ---
> >  2 files changed, 55 deletions(-)
>
> Reviewed-by: Peter Krempa <pkrempa@redhat.com>
>
>