[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v10 05/14, resend] rdma: introduce qemu_file_mode_is
From: |
mrhines |
Subject: |
[Qemu-devel] [PATCH v10 05/14, resend] rdma: introduce qemu_file_mode_is_not_valid() |
Date: |
Mon, 24 Jun 2013 09:46:21 -0400 |
From: "Michael R. Hines" <address@hidden>
QEMUFileRDMA also has read and write modes. This function is now
shared to reduce code duplication.
Reviewed-by: Paolo Bonzini <address@hidden>
Reviewed-by: Chegu Vinod <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Tested-by: Chegu Vinod <address@hidden>
Tested-by: Michael R. Hines <address@hidden>
Signed-off-by: Michael R. Hines <address@hidden>
---
include/migration/qemu-file.h | 1 +
savevm.c | 20 +++++++++++++-------
2 files changed, 14 insertions(+), 7 deletions(-)
diff --git a/include/migration/qemu-file.h b/include/migration/qemu-file.h
index 8fab0dd..dd3fd51 100644
--- a/include/migration/qemu-file.h
+++ b/include/migration/qemu-file.h
@@ -80,6 +80,7 @@ void qemu_put_byte(QEMUFile *f, int v);
* The buffer should be available till it is sent asynchronously.
*/
void qemu_put_buffer_async(QEMUFile *f, const uint8_t *buf, int size);
+bool qemu_file_mode_is_not_valid(const char *mode);
static inline void qemu_put_ubyte(QEMUFile *f, unsigned int v)
{
diff --git a/savevm.c b/savevm.c
index 2122bf0..1de6728 100644
--- a/savevm.c
+++ b/savevm.c
@@ -449,14 +449,23 @@ static const QEMUFileOps socket_write_ops = {
.close = socket_close
};
-QEMUFile *qemu_fopen_socket(int fd, const char *mode)
+bool qemu_file_mode_is_not_valid(const char *mode)
{
- QEMUFileSocket *s = g_malloc0(sizeof(QEMUFileSocket));
-
if (mode == NULL ||
(mode[0] != 'r' && mode[0] != 'w') ||
mode[1] != 'b' || mode[2] != 0) {
fprintf(stderr, "qemu_fopen: Argument validity check failed\n");
+ return true;
+ }
+
+ return false;
+}
+
+QEMUFile *qemu_fopen_socket(int fd, const char *mode)
+{
+ QEMUFileSocket *s = g_malloc0(sizeof(QEMUFileSocket));
+
+ if (qemu_file_mode_is_not_valid(mode)) {
return NULL;
}
@@ -474,10 +483,7 @@ QEMUFile *qemu_fopen(const char *filename, const char
*mode)
{
QEMUFileStdio *s;
- if (mode == NULL ||
- (mode[0] != 'r' && mode[0] != 'w') ||
- mode[1] != 'b' || mode[2] != 0) {
- fprintf(stderr, "qemu_fopen: Argument validity check failed\n");
+ if (qemu_file_mode_is_not_valid(mode)) {
return NULL;
}
--
1.7.10.4
- Re: [Qemu-devel] [PATCH v10 14/14, resend] rdma: add setup time accounting to QMP statistics, (continued)
[Qemu-devel] [PATCH v10 11/14, resend] rdma: core logic, mrhines, 2013/06/24
[Qemu-devel] [PATCH v10 10/14, resend] rdma: introduce capability x-rdma-pin-all, mrhines, 2013/06/24
[Qemu-devel] [PATCH v10 03/14, resend] rdma: export yield_until_fd_readable(), mrhines, 2013/06/24
[Qemu-devel] [PATCH v10 04/14, resend] rdma: export throughput w/ MigrationStats QMP, mrhines, 2013/06/24
[Qemu-devel] [PATCH v10 06/14, resend] rdma: export qemu_fflush(), mrhines, 2013/06/24
[Qemu-devel] [PATCH v10 13/14, resend] rdma: fix mlock() freezes and accounting, mrhines, 2013/06/24
[Qemu-devel] [PATCH v10 09/14, resend] rdma: new QEMUFileOps hooks, mrhines, 2013/06/24
[Qemu-devel] [PATCH v10 05/14, resend] rdma: introduce qemu_file_mode_is_not_valid(),
mrhines <=
[Qemu-devel] [PATCH v10 02/14, resend] rdma: introduce qemu_update_position(), mrhines, 2013/06/24