guest interface/address management using hackish mconsole exec patch, ruby bindings

This commit is contained in:
Martin Willi
2008-07-07 14:56:04 +00:00
parent 36beca7cef
commit 02a6083633
8 changed files with 291 additions and 2 deletions
+25
View File
@@ -25,6 +25,7 @@
#include <signal.h>
#include <dirent.h>
#include <termios.h>
#include <stdarg.h>
#include <debug.h>
#include <utils/linked_list.h>
@@ -324,6 +325,29 @@ static bool load_template(private_guest_t *this, char *path)
return TRUE;
}
/**
* Implementation of gues_t.exec
*/
static int exec(private_guest_t *this, char *cmd, ...)
{
char buf[512];
size_t len;
va_list args;
if (this->mconsole)
{
va_start(args, cmd);
len = vsnprintf(buf, sizeof(buf), cmd, args);
va_end(args);
if (len > 0 && len < sizeof(buf))
{
return this->mconsole->exec(this->mconsole, buf);
}
}
return FALSE;
}
/**
* Implementation of guest_t.sigchild.
*/
@@ -448,6 +472,7 @@ static private_guest_t *guest_create_generic(char *parent, char *name,
this->public.start = (void*)start;
this->public.stop = (void*)stop;
this->public.load_template = (bool(*)(guest_t*, char *path))load_template;
this->public.exec = (bool(*)(guest_t*, char *cmd, ...))exec;
this->public.sigchild = (void(*)(guest_t*))sigchild;
this->public.destroy = (void*)destroy;