/* * virsh.c: a Xen shell used to exercise the libvirt API * * Copyright (C) 2005 Red Hat, Inc. * * See COPYING.LIB for the License of this software * * Daniel Veillard * Karel Zak * Daniel P. Berrange * * * $Id$ */ #define _GNU_SOURCE /* isblank() */ #include "libvirt/libvirt.h" #include "libvirt/virterror.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include "config.h" #include "internal.h" #include "console.h" static char *progname; #ifndef TRUE #define TRUE 1 #define FALSE 0 #endif #define VSH_PROMPT_RW "virsh # " #define VSH_PROMPT_RO "virsh > " #define GETTIMEOFDAY(T) gettimeofday(T, NULL) #define DIFF_MSEC(T, U) \ ((((int) ((T)->tv_sec - (U)->tv_sec)) * 1000000.0 + \ ((int) ((T)->tv_usec - (U)->tv_usec))) / 1000.0) /* * The error handler for virtsh */ static void virshErrorHandler(void *unused, virErrorPtr error) { if ((unused != NULL) || (error == NULL)) return; /* Suppress the VIR_ERR_NO_XEN error which fails as non-root */ if ((error->code == VIR_ERR_NO_XEN) || (error->code == VIR_ERR_OK)) return; virDefaultErrorFunc(error); } /* * virsh command line grammar: * * command_line = \n | ; ; ... * * command =