mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-07-31 06:13:53 -06:00
rdma: introduce qemu_file_mode_is_not_valid()
QEMUFileRDMA also has read and write modes. This function is now shared to reduce code duplication. Reviewed-by: Juan Quintela <quintela@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Chegu Vinod <chegu_vinod@hp.com> Tested-by: Chegu Vinod <chegu_vinod@hp.com> Tested-by: Michael R. Hines <mrhines@us.ibm.com> Signed-off-by: Michael R. Hines <mrhines@us.ibm.com> Signed-off-by: Juan Quintela <quintela@redhat.com>
This commit is contained in:
parent
7e114f8cf2
commit
bc1256f7f1
2 changed files with 14 additions and 7 deletions
|
@ -80,6 +80,7 @@ void qemu_put_byte(QEMUFile *f, int v);
|
||||||
* The buffer should be available till it is sent asynchronously.
|
* The buffer should be available till it is sent asynchronously.
|
||||||
*/
|
*/
|
||||||
void qemu_put_buffer_async(QEMUFile *f, const uint8_t *buf, int size);
|
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)
|
static inline void qemu_put_ubyte(QEMUFile *f, unsigned int v)
|
||||||
{
|
{
|
||||||
|
|
20
savevm.c
20
savevm.c
|
@ -449,14 +449,23 @@ static const QEMUFileOps socket_write_ops = {
|
||||||
.close = socket_close
|
.close = socket_close
|
||||||
};
|
};
|
||||||
|
|
||||||
QEMUFile *qemu_fopen_socket(int fd, const char *mode)
|
bool qemu_file_mode_is_not_valid(const char *mode)
|
||||||
{
|
{
|
||||||
QEMUFileSocket *s;
|
|
||||||
|
|
||||||
if (mode == NULL ||
|
if (mode == NULL ||
|
||||||
(mode[0] != 'r' && mode[0] != 'w') ||
|
(mode[0] != 'r' && mode[0] != 'w') ||
|
||||||
mode[1] != 'b' || mode[2] != 0) {
|
mode[1] != 'b' || mode[2] != 0) {
|
||||||
fprintf(stderr, "qemu_fopen: Argument validity check failed\n");
|
fprintf(stderr, "qemu_fopen: Argument validity check failed\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
QEMUFile *qemu_fopen_socket(int fd, const char *mode)
|
||||||
|
{
|
||||||
|
QEMUFileSocket *s;
|
||||||
|
|
||||||
|
if (qemu_file_mode_is_not_valid(mode)) {
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -475,10 +484,7 @@ QEMUFile *qemu_fopen(const char *filename, const char *mode)
|
||||||
{
|
{
|
||||||
QEMUFileStdio *s;
|
QEMUFileStdio *s;
|
||||||
|
|
||||||
if (mode == NULL ||
|
if (qemu_file_mode_is_not_valid(mode)) {
|
||||||
(mode[0] != 'r' && mode[0] != 'w') ||
|
|
||||||
mode[1] != 'b' || mode[2] != 0) {
|
|
||||||
fprintf(stderr, "qemu_fopen: Argument validity check failed\n");
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue