From d098bc98d6232404d6e445f2a4752c2c099f9b97 Mon Sep 17 00:00:00 2001 From: Amit Shah Date: Mon, 11 Feb 2013 11:38:12 +0530 Subject: 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 --- auto-virtserial-guest.c | 19 ++++++++++++++----- 1 file 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 #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; -- cgit