[libvirt] [PATCH] qemu: guest agent: introduce new error code VIR_ERR_AGENT_UNSYNCED

From: Yuri Pudgorodskiy <yur@virtuozzo.com> A separate error code will help recognize real failures from necessity to try again Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com> --- include/libvirt/virterror.h | 2 ++ src/qemu/qemu_agent.c | 6 +++--- src/util/virerror.c | 6 ++++++ 3 files changed, 11 insertions(+), 3 deletions(-) diff --git a/include/libvirt/virterror.h b/include/libvirt/virterror.h index 2ec560e..efe83aa 100644 --- a/include/libvirt/virterror.h +++ b/include/libvirt/virterror.h @@ -315,6 +315,8 @@ typedef enum { VIR_ERR_AUTH_UNAVAILABLE = 94, /* authentication unavailable */ VIR_ERR_NO_SERVER = 95, /* Server was not found */ VIR_ERR_NO_CLIENT = 96, /* Client was not found */ + VIR_ERR_AGENT_UNSYNCED = 97, /* guest agent replies with wrong id + to guest-sync command */ } virErrorNumber; /** diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index eeede6b..fdc4fed 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -966,21 +966,21 @@ qemuAgentGuestSync(qemuAgentPtr mon) goto cleanup; if (!sync_msg.rxObject) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_AGENT_UNSYNCED, "%s", _("Missing monitor reply object")); goto cleanup; } if (virJSONValueObjectGetNumberUlong(sync_msg.rxObject, "return", &id_ret) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + virReportError(VIR_ERR_AGENT_UNSYNCED, "%s", _("Malformed return value")); goto cleanup; } VIR_DEBUG("Guest returned ID: %llu", id_ret); if (id_ret != id) { - virReportError(VIR_ERR_INTERNAL_ERROR, + virReportError(VIR_ERR_AGENT_UNSYNCED, _("Guest agent returned ID: %llu instead of %llu"), id_ret, id); goto cleanup; diff --git a/src/util/virerror.c b/src/util/virerror.c index 1177570..2958308 100644 --- a/src/util/virerror.c +++ b/src/util/virerror.c @@ -1394,6 +1394,12 @@ virErrorMsg(virErrorNumber error, const char *info) else errmsg = _("Client not found: %s"); break; + case VIR_ERR_AGENT_UNSYNCED: + if (info == NULL) + errmsg = _("guest agent replied with wrong id to guest-sync command"); + else + errmsg = _("guest agent replied with wrong id to guest-sync command: %s"); + break; } return errmsg; } -- 2.4.11

On 05.09.2016 18:42, Maxim Nestratov wrote:
From: Yuri Pudgorodskiy <yur@virtuozzo.com>
A separate error code will help recognize real failures from necessity to try again
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com> --- include/libvirt/virterror.h | 2 ++ src/qemu/qemu_agent.c | 6 +++--- src/util/virerror.c | 6 ++++++ 3 files changed, 11 insertions(+), 3 deletions(-)
ACK Just curious - have you experienced this behaviour? Michal

06-Sep-16 18:03, Michal Privoznik пишет:
On 05.09.2016 18:42, Maxim Nestratov wrote:
From: Yuri Pudgorodskiy <yur@virtuozzo.com>
A separate error code will help recognize real failures from necessity to try again
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com> --- include/libvirt/virterror.h | 2 ++ src/qemu/qemu_agent.c | 6 +++--- src/util/virerror.c | 6 ++++++ 3 files changed, 11 insertions(+), 3 deletions(-) ACK
Just curious - have you experienced this behaviour?
Michal
Yeah, pretty often. Maxim

On 9/6/2016 6:03 PM, Michal Privoznik wrote:
On 05.09.2016 18:42, Maxim Nestratov wrote:
From: Yuri Pudgorodskiy <yur@virtuozzo.com>
A separate error code will help recognize real failures from necessity to try again
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com> --- include/libvirt/virterror.h | 2 ++ src/qemu/qemu_agent.c | 6 +++--- src/util/virerror.c | 6 ++++++ 3 files changed, 11 insertions(+), 3 deletions(-) ACK
Just curious - have you experienced this behaviour?
Michal .
Issue any GA command while domains is just booted gives a good chance of the following: - domain is started running - virtio agent.0 channel is already connected to guest, but qemu-ga is not ready yet - a libvirt client issues any GA commands - command begins with guest-sync written to virtio serial device buffer - qemu-ga did not respond within default timeout (5 seconds), client got TIMEOUT - a client repeated GA commands, waiting for GA to come up, buffer is populated with repeated guest-sync command - GA finally reads command from virtio, responding to id from the 1st guest-sync found in channel (FIFO) - but libvirt now expects last id, and responds with VIR_ERR_INTERNAL_ERROR - ... VIR_ERR_INTERNAL_ERROR looks terrible from the client point of view Moreover, any timeout from qemu-ga results in VIR_ERR_AGENT_UNSYNCED error. Same scenario: - two guest agent commands one after another - 1st timeouted - libvirt is expecting response with id of the 2nd - qemu-ga finally comes with answer to the 1st - libvirt is under if (id_ret != id) condition and is responding with VIR_ERR_AGENT_UNSYNCED

06-Sep-16 18:03, Michal Privoznik пишет:
On 05.09.2016 18:42, Maxim Nestratov wrote:
From: Yuri Pudgorodskiy <yur@virtuozzo.com>
A separate error code will help recognize real failures from necessity to try again
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com> --- include/libvirt/virterror.h | 2 ++ src/qemu/qemu_agent.c | 6 +++--- src/util/virerror.c | 6 ++++++ 3 files changed, 11 insertions(+), 3 deletions(-) ACK
Just curious - have you experienced this behaviour?
Michal
Pushed now. Thanks. Maxim
participants (3)
-
Maxim Nestratov
-
Michal Privoznik
-
Yuriy Pudgorodskiy