diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2015-01-16 10:16:14 +0000 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2015-01-16 10:16:14 +0000 |
| commit | e68cba36360a2ab5bf0576b66df4d0eb0d822f8d (patch) | |
| tree | 933ecff5cc8e380fe38693dc0cca2d7b8e479dfc /migration/fd.c | |
| parent | df58887b20fab8fe8a6dcca4db30cd4e4077d53a (diff) | |
| parent | ea987c2c21d4326bb58ee28f6888fdcf8fbda067 (diff) | |
| download | focaccia-qemu-e68cba36360a2ab5bf0576b66df4d0eb0d822f8d.tar.gz focaccia-qemu-e68cba36360a2ab5bf0576b66df4d0eb0d822f8d.zip | |
Merge remote-tracking branch 'remotes/amit-migration/tags/mig-2.3-1' into staging
A set of patches collected over the holidays. Mix of optimizations and fixes. # gpg: Signature made Fri 16 Jan 2015 07:42:00 GMT using RSA key ID 854083B6 # gpg: Good signature from "Amit Shah <amit@amitshah.net>" # gpg: aka "Amit Shah <amit@kernel.org>" # gpg: aka "Amit Shah <amitshah@gmx.net>" * remotes/amit-migration/tags/mig-2.3-1: vmstate: type-check sub-arrays migration_cancel: shutdown migration socket Handle bi-directional communication for fd migration socket shutdown Tests: QEMUSizedBuffer/QEMUBuffer QEMUSizedBuffer: only free qsb that qemu_bufopen allocated xbzrle: rebuild the cache_is_cached function xbzrle: optimize XBZRLE to decrease the cache misses Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'migration/fd.c')
| -rw-r--r-- | migration/fd.c | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/migration/fd.c b/migration/fd.c index d2e523af74..129da9910b 100644 --- a/migration/fd.c +++ b/migration/fd.c @@ -31,13 +31,29 @@ do { } while (0) #endif +static bool fd_is_socket(int fd) +{ + struct stat stat; + int ret = fstat(fd, &stat); + if (ret == -1) { + /* When in doubt say no */ + return false; + } + return S_ISSOCK(stat.st_mode); +} + void fd_start_outgoing_migration(MigrationState *s, const char *fdname, Error **errp) { int fd = monitor_get_fd(cur_mon, fdname, errp); if (fd == -1) { return; } - s->file = qemu_fdopen(fd, "wb"); + + if (fd_is_socket(fd)) { + s->file = qemu_fopen_socket(fd, "wb"); + } else { + s->file = qemu_fdopen(fd, "wb"); + } migrate_fd_connect(s); } @@ -58,7 +74,11 @@ void fd_start_incoming_migration(const char *infd, Error **errp) DPRINTF("Attempting to start an incoming migration via fd\n"); fd = strtol(infd, NULL, 0); - f = qemu_fdopen(fd, "rb"); + if (fd_is_socket(fd)) { + f = qemu_fopen_socket(fd, "rb"); + } else { + f = qemu_fdopen(fd, "rb"); + } if(f == NULL) { error_setg_errno(errp, errno, "failed to open the source descriptor"); return; |