mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-03-07 17:28:15 +00:00
Fri Feb 23 09:03:19 IST 2007 Mark McLoughlin <markmc@redhat.com>
* qemud/internal.h: put the config directory paths in an array in order to make them easier to initialize, but still expose pointers to each of them as members in the server struct. * qemud/qemud.c: cleanup the config directory path initialization.
This commit is contained in:
parent
56d2857f95
commit
08cfcae91b
10
ChangeLog
10
ChangeLog
@ -1,3 +1,13 @@
|
|||||||
|
Fri Feb 23 09:03:19 IST 2007 Mark McLoughlin <markmc@redhat.com>
|
||||||
|
|
||||||
|
* qemud/internal.h: put the config directory paths in
|
||||||
|
an array in order to make them easier to initialize,
|
||||||
|
but still expose pointers to each of them as members
|
||||||
|
in the server struct.
|
||||||
|
|
||||||
|
* qemud/qemud.c: cleanup the config directory path
|
||||||
|
initialization.
|
||||||
|
|
||||||
Fri Feb 23 09:03:19 IST 2007 Mark McLoughlin <markmc@redhat.com>
|
Fri Feb 23 09:03:19 IST 2007 Mark McLoughlin <markmc@redhat.com>
|
||||||
|
|
||||||
* qemud/driver.c: maintain the autostart flag on disk
|
* qemud/driver.c: maintain the autostart flag on disk
|
||||||
|
@ -54,6 +54,15 @@ typedef enum {
|
|||||||
#endif
|
#endif
|
||||||
} qemudLogPriority;
|
} qemudLogPriority;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
QEMUD_DIR_CONFIG = 0,
|
||||||
|
QEMUD_DIR_AUTOSTART,
|
||||||
|
QEMUD_DIR_NETWORK_CONFIG,
|
||||||
|
QEMUD_DIR_NETWORK_AUTOSTART,
|
||||||
|
|
||||||
|
QEMUD_N_CONFIG_DIRS
|
||||||
|
} qemudConfigDirType;
|
||||||
|
|
||||||
/* Different types of QEMU acceleration possible */
|
/* Different types of QEMU acceleration possible */
|
||||||
enum qemud_vm_virt_type {
|
enum qemud_vm_virt_type {
|
||||||
QEMUD_VIRT_QEMU,
|
QEMUD_VIRT_QEMU,
|
||||||
@ -293,10 +302,11 @@ struct qemud_server {
|
|||||||
struct qemud_network *networks;
|
struct qemud_network *networks;
|
||||||
brControl *brctl;
|
brControl *brctl;
|
||||||
iptablesContext *iptables;
|
iptablesContext *iptables;
|
||||||
char configDir[PATH_MAX];
|
char configDirs[QEMUD_N_CONFIG_DIRS][PATH_MAX];
|
||||||
char networkConfigDir[PATH_MAX];
|
char *configDir;
|
||||||
char autostartDir[PATH_MAX];
|
char *autostartDir;
|
||||||
char networkAutostartDir[PATH_MAX];
|
char *networkConfigDir;
|
||||||
|
char *networkAutostartDir;
|
||||||
char errorMessage[QEMUD_MAX_ERROR_LEN];
|
char errorMessage[QEMUD_MAX_ERROR_LEN];
|
||||||
int errorCode;
|
int errorCode;
|
||||||
unsigned int shutdown : 1;
|
unsigned int shutdown : 1;
|
||||||
|
@ -354,15 +354,22 @@ static int qemudListenUnix(struct qemud_server *server,
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int qemudInitPaths(int sys,
|
static int qemudInitPaths(struct qemud_server *server,
|
||||||
char *configDir,
|
int sys,
|
||||||
char *networkConfigDir,
|
|
||||||
char *autostartDir,
|
|
||||||
char *networkAutostartDir,
|
|
||||||
char *sockname,
|
char *sockname,
|
||||||
char *roSockname,
|
char *roSockname,
|
||||||
int maxlen) {
|
int maxlen) {
|
||||||
|
const char *paths[] = {
|
||||||
|
"libvirt/qemu", /* QEMUD_DIR_DOMAINS */
|
||||||
|
"libvirt/qemu/autostart", /* QEMUD_DIR_AUTO_DOMAINS */
|
||||||
|
"libvirt/qemu/networks", /* QEMUD_DIR_NETWORKS */
|
||||||
|
"libvirt/qemu/networks/autostart", /* QEMUD_DIR_AUTO_NETWORKS */
|
||||||
|
};
|
||||||
|
|
||||||
uid_t uid;
|
uid_t uid;
|
||||||
|
struct passwd *pw;
|
||||||
|
char base[PATH_MAX] = SYSCONF_DIR "/";
|
||||||
|
int i;
|
||||||
|
|
||||||
uid = geteuid();
|
uid = geteuid();
|
||||||
|
|
||||||
@ -372,18 +379,6 @@ static int qemudInitPaths(int sys,
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (snprintf(configDir, maxlen, "%s/libvirt/qemu", SYSCONF_DIR) >= maxlen)
|
|
||||||
goto snprintf_error;
|
|
||||||
|
|
||||||
if (snprintf(networkConfigDir, maxlen, "%s/libvirt/qemu/networks", SYSCONF_DIR) >= maxlen)
|
|
||||||
goto snprintf_error;
|
|
||||||
|
|
||||||
if (snprintf(autostartDir, maxlen, "%s/libvirt/qemu/autostart", SYSCONF_DIR) >= maxlen)
|
|
||||||
goto snprintf_error;
|
|
||||||
|
|
||||||
if (snprintf(networkAutostartDir, maxlen, "%s/libvirt/qemu/networks/autostart", SYSCONF_DIR) >= maxlen)
|
|
||||||
goto snprintf_error;
|
|
||||||
|
|
||||||
if (snprintf(sockname, maxlen, "%s/run/libvirt/qemud-sock", LOCAL_STATE_DIR) >= maxlen)
|
if (snprintf(sockname, maxlen, "%s/run/libvirt/qemud-sock", LOCAL_STATE_DIR) >= maxlen)
|
||||||
goto snprintf_error;
|
goto snprintf_error;
|
||||||
|
|
||||||
@ -394,30 +389,23 @@ static int qemudInitPaths(int sys,
|
|||||||
|
|
||||||
unlink(sockname);
|
unlink(sockname);
|
||||||
} else {
|
} else {
|
||||||
struct passwd *pw;
|
|
||||||
|
|
||||||
if (!(pw = getpwuid(uid))) {
|
if (!(pw = getpwuid(uid))) {
|
||||||
qemudLog(QEMUD_ERR, "Failed to find user record for uid '%d': %s",
|
qemudLog(QEMUD_ERR, "Failed to find user record for uid '%d': %s",
|
||||||
uid, strerror(errno));
|
uid, strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (snprintf(configDir, maxlen, "%s/.libvirt/qemu", pw->pw_dir) >= maxlen)
|
|
||||||
goto snprintf_error;
|
|
||||||
|
|
||||||
if (snprintf(networkConfigDir, maxlen, "%s/.libvirt/qemu/networks", pw->pw_dir) >= maxlen)
|
|
||||||
goto snprintf_error;
|
|
||||||
|
|
||||||
if (snprintf(autostartDir, maxlen, "%s/.libvirt/qemu/autostart", pw->pw_dir) >= maxlen)
|
|
||||||
goto snprintf_error;
|
|
||||||
|
|
||||||
if (snprintf(networkAutostartDir, maxlen, "%s/.libvirt/qemu/networks/autostart", pw->pw_dir) >= maxlen)
|
|
||||||
goto snprintf_error;
|
|
||||||
|
|
||||||
if (snprintf(sockname, maxlen, "@%s/.libvirt/qemud-sock", pw->pw_dir) >= maxlen)
|
if (snprintf(sockname, maxlen, "@%s/.libvirt/qemud-sock", pw->pw_dir) >= maxlen)
|
||||||
goto snprintf_error;
|
goto snprintf_error;
|
||||||
|
|
||||||
|
if (snprintf(base, PATH_MAX, "%s/.", pw->pw_dir) >= PATH_MAX)
|
||||||
|
goto snprintf_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (i = 0; i < QEMUD_N_CONFIG_DIRS; i++)
|
||||||
|
if (snprintf(server->configDirs[i], PATH_MAX, "%s%s", base, paths[i]) >= PATH_MAX)
|
||||||
|
goto snprintf_error;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
snprintf_error:
|
snprintf_error:
|
||||||
@ -443,11 +431,14 @@ static struct qemud_server *qemudInitialize(int sys, int sigread) {
|
|||||||
|
|
||||||
roSockname[0] = '\0';
|
roSockname[0] = '\0';
|
||||||
|
|
||||||
if (qemudInitPaths(sys, server->configDir, server->networkConfigDir,
|
if (qemudInitPaths(server, sys, sockname, roSockname, PATH_MAX) < 0)
|
||||||
server->autostartDir, server->networkAutostartDir,
|
|
||||||
sockname, roSockname, PATH_MAX) < 0)
|
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
server->configDir = server->configDirs[QEMUD_DIR_CONFIG];
|
||||||
|
server->autostartDir = server->configDirs[QEMUD_DIR_AUTOSTART];
|
||||||
|
server->networkConfigDir = server->configDirs[QEMUD_DIR_NETWORK_CONFIG];
|
||||||
|
server->networkAutostartDir = server->configDirs[QEMUD_DIR_NETWORK_AUTOSTART];
|
||||||
|
|
||||||
if (qemudListenUnix(server, sockname, 0) < 0)
|
if (qemudListenUnix(server, sockname, 0) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user