diff options
author | Amit Shah <amit.shah@redhat.com> | 2013-02-11 11:38:12 +0530 |
---|---|---|
committer | Amit Shah <amit.shah@redhat.com> | 2013-02-11 11:41:05 +0530 |
commit | d098bc98d6232404d6e445f2a4752c2c099f9b97 (patch) | |
tree | 8a4c7cc8c591b529c3cee3771dc35410e3a2e139 | |
parent | 12cdb5f01e4a5030e0f92985f25b08f4c06be914 (diff) | |
download | test-virtserial-d098bc98d6232404d6e445f2a4752c2c099f9b97.tar.gz test-virtserial-d098bc98d6232404d6e445f2a4752c2c099f9b97.tar.xz test-virtserial-d098bc98d6232404d6e445f2a4752c2c099f9b97.zip |
auto-guest: try opening port by name before opening by id
The control channel for the tests is named 'test0', and is always the
first port of the first device we add (/dev/vport0p0). However, the
device number can change based on pending upstream patches, so instead
of relying on the id, try opening by name first.
Signed-off-by: Amit Shah <amit.shah@redhat.com>
-rw-r--r-- | auto-virtserial-guest.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/auto-virtserial-guest.c b/auto-virtserial-guest.c index cfa90b7..53d815d 100644 --- a/auto-virtserial-guest.c +++ b/auto-virtserial-guest.c @@ -35,7 +35,8 @@ #include <sys/wait.h> #include "virtserial.h" -#define CONTROL_PORT "/dev/vport0p1" +#define CONTROL_PORT "/dev/virtio-ports/test0" +#define CONTROL_PORT2 "/dev/vport0p1" #define MAX_PORTS 10 /* The fd to work with for read / write requests. Set by the open message */ @@ -604,13 +605,21 @@ int main(int argc, char *argv[]) install_sigio_handler(); ret = access(CONTROL_PORT, R_OK|W_OK); - if (ret == -1) - error(errno, errno, "No control port found %s", CONTROL_PORT); + if (ret == -1) { + ret = access(CONTROL_PORT2, R_OK|W_OK); + if (ret == -1) { + error(errno, errno, "No control port found %s or %s", CONTROL_PORT, CONTROL_PORT2); + } + } back_to_open: cfd = open(CONTROL_PORT, O_RDWR); - if (cfd == -1) - error(errno, errno, "open control port %s", CONTROL_PORT); + if (cfd == -1) { + cfd = open(CONTROL_PORT2, O_RDWR); + if (cfd == -1) { + error(errno, errno, "open control port %s", CONTROL_PORT); + } + } gpkt.key = KEY_STATUS_OK; gpkt.value = 1; |