qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Basil Salman <basil@daynix.com>
To: qemu-devel@nongnu.org, Michael Roth <mdroth@linux.vnet.ibm.com>
Cc: Yan Vugenfirer <yan@daynix.com>, Bishara AbuHattoum <bishara@daynix.com>
Subject: [Qemu-devel] [PATCH v2 2/4] qga: fix send_response error handling
Date: Sun, 13 Jan 2019 12:05:29 +0200	[thread overview]
Message-ID: <20190113100531.1346024-3-basil@daynix.com> (raw)
In-Reply-To: <20190113100531.1346024-1-basil@daynix.com>

Sometimes qemu-ga fails to send a response to client due to memory allocation
issues due to a large response message, this can be experienced while trying
to read large number of bytes using QMP command guest-file-read.

Added a check to send an error response to qemu-ga client in such cases.

Signed-off-by: Basil Salman <basil@daynix.com>
---
 qga/main.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/qga/main.c b/qga/main.c
index 87a0711c14..964275c40c 100644
--- a/qga/main.c
+++ b/qga/main.c
@@ -561,6 +561,8 @@ static void process_command(GAState *s, QDict *req)
 {
     QDict *rsp;
     int ret;
+    QDict *ersp;
+    Error *err = NULL;
 
     g_assert(req);
     g_debug("processing command");
@@ -569,9 +571,20 @@ static void process_command(GAState *s, QDict *req)
         ret = send_response(s, rsp);
         if (ret < 0) {
             g_warning("error sending response: %s", strerror(-ret));
+            goto err;
         }
         qobject_unref(rsp);
     }
+    return;
+err:
+    error_setg(&err, "Insufficient system resources exist to "
+                      "complete the requested service");
+    ersp = qmp_error_response(err);
+    ret = send_response(s, ersp);
+    if (ret < 0) {
+        g_warning("error sending error response: %s", strerror(-ret));
+    }
+    qobject_unref(ersp);
 }
 
 /* handle requests/control events coming in over the channel */
-- 
2.17.2

  parent reply	other threads:[~2019-01-13 10:05 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-13 10:05 [Qemu-devel] [PATCH v2 0/4] QGA - Win fixes Basil Salman
2019-01-13 10:05 ` [Qemu-devel] [PATCH v2 1/4] qga-win: prevent crash when executing guest-file-read with large count Basil Salman
2019-01-24 16:44   ` Michael Roth
2019-01-13 10:05 ` Basil Salman [this message]
2019-01-24 17:18   ` [Qemu-devel] [PATCH v2 2/4] qga: fix send_response error handling Michael Roth
2019-01-13 10:05 ` [Qemu-devel] [PATCH v2 3/4] qga: Installer: Wait for installation to finish Basil Salman
2019-01-13 10:05 ` [Qemu-devel] [PATCH v2 4/4] qga-win: Handle VSS_E_PROVIDER_ALREADY_REGISTERED error Basil Salman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190113100531.1346024-3-basil@daynix.com \
    --to=basil@daynix.com \
    --cc=bishara@daynix.com \
    --cc=mdroth@linux.vnet.ibm.com \
    --cc=qemu-devel@nongnu.org \
    --cc=yan@daynix.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).