Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
b63f8cc9
L
libvirt
项目概览
openeuler
/
libvirt
通知
3
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
L
libvirt
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b63f8cc9
编写于
6月 26, 2007
作者:
D
Daniel P. Berrange
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Split up struct qemud_server to move qemu stuff into conf.c
上级
498cc578
变更
8
展开全部
显示空白变更内容
内联
并排
Showing
8 changed file
with
927 addition
and
892 deletion
+927
-892
ChangeLog
ChangeLog
+8
-0
qemud/conf.c
qemud/conf.c
+116
-123
qemud/conf.h
qemud/conf.h
+277
-15
qemud/dispatch.c
qemud/dispatch.c
+121
-160
qemud/driver.c
qemud/driver.c
+356
-261
qemud/driver.h
qemud/driver.h
+41
-57
qemud/internal.h
qemud/internal.h
+0
-236
qemud/qemud.c
qemud/qemud.c
+8
-40
未找到文件。
ChangeLog
浏览文件 @
b63f8cc9
Tue Jun 26 18:10:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* qemud/conf.c, qemud/conf.h, qemud/dispatch.c, qemud/driver.c,
qemud/driver.h, qemud/internal.h, qemud/qemud.c: Split the
struct qemud_server into two parts, moving QEMU stuff out into
struct qemud_driver. Move all QEMU related data structures
and manipulation code into conf.c file
Tue Jun 26 16:50:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* qemud/Makefile.am, qemud/conf.c, qemud/dispatch.c, qemud/driver.c,
...
...
qemud/conf.c
浏览文件 @
b63f8cc9
此差异已折叠。
点击以展开。
qemud/conf.h
浏览文件 @
b63f8cc9
...
...
@@ -24,15 +24,277 @@
#ifndef __QEMUD_CONF_H
#define __QEMUD_CONF_H
#include "internal.h"
/* Different types of QEMU acceleration possible */
enum
qemud_vm_virt_type
{
QEMUD_VIRT_QEMU
,
QEMUD_VIRT_KQEMU
,
QEMUD_VIRT_KVM
,
};
/* Two types of disk backends */
enum
qemud_vm_disk_type
{
QEMUD_DISK_BLOCK
,
QEMUD_DISK_FILE
};
/* Three types of disk frontend */
enum
qemud_vm_disk_device
{
QEMUD_DISK_DISK
,
QEMUD_DISK_CDROM
,
QEMUD_DISK_FLOPPY
,
};
/* Stores the virtual disk configuration */
struct
qemud_vm_disk_def
{
int
type
;
int
device
;
char
src
[
PATH_MAX
];
char
dst
[
NAME_MAX
];
int
readonly
;
struct
qemud_vm_disk_def
*
next
;
};
#define QEMUD_MAC_ADDRESS_LEN 6
#define QEMUD_OS_TYPE_MAX_LEN 10
#define QEMUD_OS_ARCH_MAX_LEN 10
#define QEMUD_OS_MACHINE_MAX_LEN 10
/* 5 different types of networking config */
enum
qemud_vm_net_type
{
QEMUD_NET_USER
,
QEMUD_NET_ETHERNET
,
QEMUD_NET_SERVER
,
QEMUD_NET_CLIENT
,
QEMUD_NET_MCAST
,
QEMUD_NET_NETWORK
,
QEMUD_NET_BRIDGE
,
};
/* Stores the virtual network interface configuration */
struct
qemud_vm_net_def
{
int
type
;
unsigned
char
mac
[
QEMUD_MAC_ADDRESS_LEN
];
union
{
struct
{
char
ifname
[
BR_IFNAME_MAXLEN
];
char
script
[
PATH_MAX
];
}
ethernet
;
struct
{
char
address
[
BR_INET_ADDR_MAXLEN
];
int
port
;
}
socket
;
/* any of NET_CLIENT or NET_SERVER or NET_MCAST */
struct
{
char
name
[
QEMUD_MAX_NAME_LEN
];
char
ifname
[
BR_IFNAME_MAXLEN
];
}
network
;
struct
{
char
brname
[
BR_IFNAME_MAXLEN
];
char
ifname
[
BR_IFNAME_MAXLEN
];
}
bridge
;
}
dst
;
struct
qemud_vm_net_def
*
next
;
};
#define QEMUD_MAX_BOOT_DEVS 4
/* 3 possible boot devices */
enum
qemud_vm_boot_order
{
QEMUD_BOOT_FLOPPY
,
QEMUD_BOOT_CDROM
,
QEMUD_BOOT_DISK
,
QEMUD_BOOT_NET
,
};
/* 3 possible graphics console modes */
enum
qemud_vm_grapics_type
{
QEMUD_GRAPHICS_NONE
,
QEMUD_GRAPHICS_SDL
,
QEMUD_GRAPHICS_VNC
,
};
/* Internal flags to keep track of qemu command line capabilities */
enum
qemud_cmd_flags
{
QEMUD_CMD_FLAG_KQEMU
=
1
,
QEMUD_CMD_FLAG_VNC_COLON
=
2
,
QEMUD_CMD_FLAG_NO_REBOOT
=
4
,
};
enum
qemud_vm_features
{
QEMUD_FEATURE_ACPI
=
1
,
};
/* Operating system configuration data & machine / arch */
struct
qemud_vm_os_def
{
char
type
[
QEMUD_OS_TYPE_MAX_LEN
];
char
arch
[
QEMUD_OS_ARCH_MAX_LEN
];
char
machine
[
QEMUD_OS_MACHINE_MAX_LEN
];
int
nBootDevs
;
int
bootDevs
[
QEMUD_MAX_BOOT_DEVS
];
char
kernel
[
PATH_MAX
];
char
initrd
[
PATH_MAX
];
char
cmdline
[
PATH_MAX
];
char
binary
[
PATH_MAX
];
};
/* Guest VM main configuration */
struct
qemud_vm_def
{
int
virtType
;
unsigned
char
uuid
[
QEMUD_UUID_RAW_LEN
];
char
name
[
QEMUD_MAX_NAME_LEN
];
int
memory
;
int
maxmem
;
int
vcpus
;
int
noReboot
;
struct
qemud_vm_os_def
os
;
int
features
;
int
graphicsType
;
int
vncPort
;
int
vncActivePort
;
int
ndisks
;
struct
qemud_vm_disk_def
*
disks
;
int
nnets
;
struct
qemud_vm_net_def
*
nets
;
};
/* Guest VM runtime state */
struct
qemud_vm
{
int
stdout
;
int
stderr
;
int
monitor
;
int
logfile
;
int
pid
;
int
id
;
int
state
;
int
*
tapfds
;
int
ntapfds
;
char
configFile
[
PATH_MAX
];
char
autostartLink
[
PATH_MAX
];
struct
qemud_vm_def
*
def
;
/* The current definition */
struct
qemud_vm_def
*
newDef
;
/* New definition to activate at shutdown */
unsigned
int
autostart
:
1
;
struct
qemud_vm
*
next
;
};
/* Store start and end addresses of a dhcp range */
struct
qemud_dhcp_range_def
{
char
start
[
BR_INET_ADDR_MAXLEN
];
char
end
[
BR_INET_ADDR_MAXLEN
];
struct
qemud_dhcp_range_def
*
next
;
};
/* Virtual Network main configuration */
struct
qemud_network_def
{
unsigned
char
uuid
[
QEMUD_UUID_RAW_LEN
];
char
name
[
QEMUD_MAX_NAME_LEN
];
char
bridge
[
BR_IFNAME_MAXLEN
];
int
disableSTP
;
int
forwardDelay
;
int
forward
;
char
forwardDev
[
BR_IFNAME_MAXLEN
];
char
ipAddress
[
BR_INET_ADDR_MAXLEN
];
char
netmask
[
BR_INET_ADDR_MAXLEN
];
char
network
[
BR_INET_ADDR_MAXLEN
+
BR_INET_ADDR_MAXLEN
+
1
];
int
nranges
;
struct
qemud_dhcp_range_def
*
ranges
;
};
/* Virtual Network runtime state */
struct
qemud_network
{
char
configFile
[
PATH_MAX
];
char
autostartLink
[
PATH_MAX
];
struct
qemud_network_def
*
def
;
/* The current definition */
struct
qemud_network_def
*
newDef
;
/* New definition to activate at shutdown */
char
bridge
[
BR_IFNAME_MAXLEN
];
int
dnsmasqPid
;
unsigned
int
active
:
1
;
unsigned
int
autostart
:
1
;
struct
qemud_network
*
next
;
};
/* Main driver state */
struct
qemud_driver
{
int
qemuVersion
;
int
qemuCmdFlags
;
/* values from enum qemud_cmd_flags */
int
nactivevms
;
int
ninactivevms
;
struct
qemud_vm
*
vms
;
int
nextvmid
;
int
nactivenetworks
;
int
ninactivenetworks
;
struct
qemud_network
*
networks
;
brControl
*
brctl
;
iptablesContext
*
iptables
;
char
*
configDir
;
char
*
autostartDir
;
char
*
networkConfigDir
;
char
*
networkAutostartDir
;
char
logDir
[
PATH_MAX
];
};
static
inline
int
qemudIsActiveVM
(
struct
qemud_vm
*
vm
)
{
return
vm
->
id
!=
-
1
;
}
static
inline
int
qemudIsActiveNetwork
(
struct
qemud_network
*
network
)
{
return
network
->
active
;
}
void
qemudReportError
(
virConnectPtr
conn
,
virDomainPtr
dom
,
virNetworkPtr
net
,
int
code
,
const
char
*
fmt
,
...)
ATTRIBUTE_FORMAT
(
printf
,
5
,
6
);
struct
qemud_vm
*
qemudFindVMByID
(
const
struct
qemud_driver
*
driver
,
int
id
);
struct
qemud_vm
*
qemudFindVMByUUID
(
const
struct
qemud_driver
*
driver
,
const
unsigned
char
*
uuid
);
struct
qemud_vm
*
qemudFindVMByName
(
const
struct
qemud_driver
*
driver
,
const
char
*
name
);
struct
qemud_network
*
qemudFindNetworkByUUID
(
const
struct
qemud_driver
*
driver
,
const
unsigned
char
*
uuid
);
struct
qemud_network
*
qemudFindNetworkByName
(
const
struct
qemud_driver
*
driver
,
const
char
*
name
);
int
qemudExtractVersion
(
struct
qemud_
server
*
ser
ver
);
int
qemudBuildCommandLine
(
struct
qemud_
server
*
ser
ver
,
int
qemudExtractVersion
(
struct
qemud_
driver
*
dri
ver
);
int
qemudBuildCommandLine
(
struct
qemud_
driver
*
dri
ver
,
struct
qemud_vm
*
vm
,
char
***
argv
);
int
qemudScanConfigs
(
struct
qemud_
server
*
ser
ver
);
int
qemudDeleteConfig
(
struct
qemud_
server
*
ser
ver
,
int
qemudScanConfigs
(
struct
qemud_
driver
*
dri
ver
);
int
qemudDeleteConfig
(
struct
qemud_
driver
*
dri
ver
,
const
char
*
configFile
,
const
char
*
name
);
int
qemudEnsureDir
(
const
char
*
path
);
...
...
@@ -41,19 +303,19 @@ void qemudFreeVMDef (struct qemud_vm_def *vm);
void
qemudFreeVM
(
struct
qemud_vm
*
vm
);
struct
qemud_vm
*
qemudAssignVMDef
(
struct
qemud_
server
*
ser
ver
,
qemudAssignVMDef
(
struct
qemud_
driver
*
dri
ver
,
struct
qemud_vm_def
*
def
);
void
qemudRemoveInactiveVM
(
struct
qemud_
server
*
ser
ver
,
void
qemudRemoveInactiveVM
(
struct
qemud_
driver
*
dri
ver
,
struct
qemud_vm
*
vm
);
struct
qemud_vm_def
*
qemudParseVMDef
(
struct
qemud_
server
*
ser
ver
,
qemudParseVMDef
(
struct
qemud_
driver
*
dri
ver
,
const
char
*
xmlStr
,
const
char
*
displayName
);
int
qemudSaveVMDef
(
struct
qemud_
server
*
ser
ver
,
int
qemudSaveVMDef
(
struct
qemud_
driver
*
dri
ver
,
struct
qemud_vm
*
vm
,
struct
qemud_vm_def
*
def
);
char
*
qemudGenerateXML
(
struct
qemud_
server
*
ser
ver
,
char
*
qemudGenerateXML
(
struct
qemud_
driver
*
dri
ver
,
struct
qemud_vm
*
vm
,
struct
qemud_vm_def
*
def
,
int
live
);
...
...
@@ -62,19 +324,19 @@ void qemudFreeNetworkDef (struct qemud_network_def *def);
void
qemudFreeNetwork
(
struct
qemud_network
*
network
);
struct
qemud_network
*
qemudAssignNetworkDef
(
struct
qemud_
server
*
ser
ver
,
qemudAssignNetworkDef
(
struct
qemud_
driver
*
dri
ver
,
struct
qemud_network_def
*
def
);
void
qemudRemoveInactiveNetwork
(
struct
qemud_
server
*
ser
ver
,
void
qemudRemoveInactiveNetwork
(
struct
qemud_
driver
*
dri
ver
,
struct
qemud_network
*
network
);
struct
qemud_network_def
*
qemudParseNetworkDef
(
struct
qemud_
server
*
ser
ver
,
qemudParseNetworkDef
(
struct
qemud_
driver
*
dri
ver
,
const
char
*
xmlStr
,
const
char
*
displayName
);
int
qemudSaveNetworkDef
(
struct
qemud_
server
*
ser
ver
,
int
qemudSaveNetworkDef
(
struct
qemud_
driver
*
dri
ver
,
struct
qemud_network
*
network
,
struct
qemud_network_def
*
def
);
char
*
qemudGenerateNetworkXML
(
struct
qemud_
server
*
ser
ver
,
char
*
qemudGenerateNetworkXML
(
struct
qemud_
driver
*
dri
ver
,
struct
qemud_network
*
network
,
struct
qemud_network_def
*
def
);
...
...
qemud/dispatch.c
浏览文件 @
b63f8cc9
此差异已折叠。
点击以展开。
qemud/driver.c
浏览文件 @
b63f8cc9
此差异已折叠。
点击以展开。
qemud/driver.h
浏览文件 @
b63f8cc9
...
...
@@ -26,28 +26,23 @@
#define QEMUD_DRIVER_H
#include "internal.h"
#include "conf.h"
int
qemudStartVMDaemon
(
struct
qemud_
server
*
ser
ver
,
int
qemudStartVMDaemon
(
struct
qemud_
driver
*
dri
ver
,
struct
qemud_vm
*
vm
);
int
qemudShutdownVMDaemon
(
struct
qemud_
server
*
ser
ver
,
int
qemudShutdownVMDaemon
(
struct
qemud_
driver
*
dri
ver
,
struct
qemud_vm
*
vm
);
int
qemudStartNetworkDaemon
(
struct
qemud_
server
*
ser
ver
,
int
qemudStartNetworkDaemon
(
struct
qemud_
driver
*
dri
ver
,
struct
qemud_network
*
network
);
int
qemudShutdownNetworkDaemon
(
struct
qemud_
server
*
ser
ver
,
int
qemudShutdownNetworkDaemon
(
struct
qemud_
driver
*
dri
ver
,
struct
qemud_network
*
network
);
int
qemudStartup
(
struct
qemud_server
*
server
);
void
qemudReload
(
struct
qemud_server
*
server
);
void
qemudShutdown
(
struct
qemud_server
*
server
);
void
qemudReportError
(
virConnectPtr
conn
,
virDomainPtr
dom
,
virNetworkPtr
net
,
int
code
,
const
char
*
fmt
,
...)
ATTRIBUTE_FORMAT
(
printf
,
5
,
6
);
int
qemudStartup
(
void
);
void
qemudReload
(
void
);
void
qemudShutdown
(
void
);
int
qemudGetNodeInfo
(
unsigned
int
*
memory
,
char
*
cpuModel
,
int
cpuModelLength
,
...
...
@@ -55,100 +50,89 @@ int qemudGetNodeInfo(unsigned int *memory,
unsigned
int
*
nodes
,
unsigned
int
*
sockets
,
unsigned
int
*
cores
,
unsigned
int
*
threads
);
char
*
qemudGetCapabilities
(
struct
qemud_
server
*
ser
ver
);
int
qemudMonitorCommand
(
struct
qemud_
server
*
ser
ver
,
char
*
qemudGetCapabilities
(
struct
qemud_
driver
*
dri
ver
);
int
qemudMonitorCommand
(
struct
qemud_
driver
*
dri
ver
,
struct
qemud_vm
*
vm
,
const
char
*
cmd
,
char
**
reply
);
struct
qemud_vm
*
qemudFindVMByID
(
const
struct
qemud_server
*
server
,
int
id
);
struct
qemud_vm
*
qemudFindVMByUUID
(
const
struct
qemud_server
*
server
,
const
unsigned
char
*
uuid
);
struct
qemud_vm
*
qemudFindVMByName
(
const
struct
qemud_server
*
server
,
const
char
*
name
);
int
qemudGetVersion
(
struct
qemud_server
*
server
);
int
qemudListDomains
(
struct
qemud_server
*
server
,
int
qemudGetVersion
(
struct
qemud_driver
*
driver
);
int
qemudListDomains
(
struct
qemud_driver
*
driver
,
int
*
ids
,
int
nids
);
int
qemudNumDomains
(
struct
qemud_
server
*
ser
ver
);
struct
qemud_vm
*
qemudDomainCreate
(
struct
qemud_
server
*
ser
ver
,
int
qemudNumDomains
(
struct
qemud_
driver
*
dri
ver
);
struct
qemud_vm
*
qemudDomainCreate
(
struct
qemud_
driver
*
dri
ver
,
const
char
*
xml
);
int
qemudDomainSuspend
(
struct
qemud_
server
*
ser
ver
,
int
qemudDomainSuspend
(
struct
qemud_
driver
*
dri
ver
,
int
id
);
int
qemudDomainResume
(
struct
qemud_
server
*
ser
ver
,
int
qemudDomainResume
(
struct
qemud_
driver
*
dri
ver
,
int
id
);
int
qemudDomainDestroy
(
struct
qemud_
server
*
ser
ver
,
int
qemudDomainDestroy
(
struct
qemud_
driver
*
dri
ver
,
int
id
);
int
qemudDomainGetInfo
(
struct
qemud_
server
*
ser
ver
,
int
qemudDomainGetInfo
(
struct
qemud_
driver
*
dri
ver
,
const
unsigned
char
*
uuid
,
int
*
runstate
,
unsigned
long
long
*
cputime
,
unsigned
long
*
maxmem
,
unsigned
long
*
memory
,
unsigned
int
*
nrVirtCpu
);
int
qemudDomainSave
(
struct
qemud_
server
*
ser
ver
,
int
qemudDomainSave
(
struct
qemud_
driver
*
dri
ver
,
int
id
,
const
char
*
path
);
int
qemudDomainRestore
(
struct
qemud_
server
*
ser
ver
,
int
qemudDomainRestore
(
struct
qemud_
driver
*
dri
ver
,
const
char
*
path
);
int
qemudDomainDumpXML
(
struct
qemud_
server
*
ser
ver
,
int
qemudDomainDumpXML
(
struct
qemud_
driver
*
dri
ver
,
const
unsigned
char
*
uuid
,
char
*
xml
,
int
xmllen
);
int
qemudListDefinedDomains
(
struct
qemud_
server
*
ser
ver
,
int
qemudListDefinedDomains
(
struct
qemud_
driver
*
dri
ver
,
char
*
const
*
names
,
int
nnames
);
int
qemudNumDefinedDomains
(
struct
qemud_
server
*
ser
ver
);
struct
qemud_vm
*
qemudDomainStart
(
struct
qemud_
server
*
ser
ver
,
int
qemudNumDefinedDomains
(
struct
qemud_
driver
*
dri
ver
);
struct
qemud_vm
*
qemudDomainStart
(
struct
qemud_
driver
*
dri
ver
,
const
unsigned
char
*
uuid
);
struct
qemud_vm
*
qemudDomainDefine
(
struct
qemud_
server
*
ser
ver
,
struct
qemud_vm
*
qemudDomainDefine
(
struct
qemud_
driver
*
dri
ver
,
const
char
*
xml
);
int
qemudDomainUndefine
(
struct
qemud_
server
*
ser
ver
,
int
qemudDomainUndefine
(
struct
qemud_
driver
*
dri
ver
,
const
unsigned
char
*
uuid
);
int
qemudDomainGetAutostart
(
struct
qemud_
server
*
ser
ver
,
int
qemudDomainGetAutostart
(
struct
qemud_
driver
*
dri
ver
,
const
unsigned
char
*
uuid
,
int
*
autostart
);
int
qemudDomainSetAutostart
(
struct
qemud_
server
*
ser
ver
,
int
qemudDomainSetAutostart
(
struct
qemud_
driver
*
dri
ver
,
const
unsigned
char
*
uuid
,
int
autostart
);
struct
qemud_network
*
qemudFindNetworkByUUID
(
const
struct
qemud_server
*
server
,
const
unsigned
char
*
uuid
);
struct
qemud_network
*
qemudFindNetworkByName
(
const
struct
qemud_server
*
server
,
const
char
*
name
);
int
qemudNumNetworks
(
struct
qemud_
server
*
ser
ver
);
int
qemudListNetworks
(
struct
qemud_
server
*
ser
ver
,
int
qemudNumNetworks
(
struct
qemud_
driver
*
dri
ver
);
int
qemudListNetworks
(
struct
qemud_
driver
*
dri
ver
,
char
*
const
*
names
,
int
nnames
);
int
qemudNumDefinedNetworks
(
struct
qemud_
server
*
ser
ver
);
int
qemudListDefinedNetworks
(
struct
qemud_
server
*
ser
ver
,
int
qemudNumDefinedNetworks
(
struct
qemud_
driver
*
dri
ver
);
int
qemudListDefinedNetworks
(
struct
qemud_
driver
*
dri
ver
,
char
*
const
*
names
,
int
nnames
);
struct
qemud_network
*
qemudNetworkCreate
(
struct
qemud_
server
*
ser
ver
,
struct
qemud_network
*
qemudNetworkCreate
(
struct
qemud_
driver
*
dri
ver
,
const
char
*
xml
);
struct
qemud_network
*
qemudNetworkDefine
(
struct
qemud_
server
*
ser
ver
,
struct
qemud_network
*
qemudNetworkDefine
(
struct
qemud_
driver
*
dri
ver
,
const
char
*
xml
);
struct
qemud_network
*
qemudNetworkStart
(
struct
qemud_
server
*
ser
ver
,
struct
qemud_network
*
qemudNetworkStart
(
struct
qemud_
driver
*
dri
ver
,
const
unsigned
char
*
uuid
);
int
qemudNetworkUndefine
(
struct
qemud_
server
*
ser
ver
,
int
qemudNetworkUndefine
(
struct
qemud_
driver
*
dri
ver
,
const
unsigned
char
*
uuid
);
int
qemudNetworkDestroy
(
struct
qemud_
server
*
ser
ver
,
int
qemudNetworkDestroy
(
struct
qemud_
driver
*
dri
ver
,
const
unsigned
char
*
uuid
);
int
qemudNetworkDumpXML
(
struct
qemud_
server
*
ser
ver
,
int
qemudNetworkDumpXML
(
struct
qemud_
driver
*
dri
ver
,
const
unsigned
char
*
uuid
,
char
*
xml
,
int
xmllen
);
int
qemudNetworkGetBridgeName
(
struct
qemud_
server
*
ser
ver
,
int
qemudNetworkGetBridgeName
(
struct
qemud_
driver
*
dri
ver
,
const
unsigned
char
*
uuid
,
char
*
ifname
,
int
ifnamelen
);
int
qemudNetworkGetAutostart
(
struct
qemud_
server
*
ser
ver
,
int
qemudNetworkGetAutostart
(
struct
qemud_
driver
*
dri
ver
,
const
unsigned
char
*
uuid
,
int
*
autostart
);
int
qemudNetworkSetAutostart
(
struct
qemud_
server
*
ser
ver
,
int
qemudNetworkSetAutostart
(
struct
qemud_
driver
*
dri
ver
,
const
unsigned
char
*
uuid
,
int
autostart
);
...
...
qemud/internal.h
浏览文件 @
b63f8cc9
...
...
@@ -61,216 +61,6 @@ typedef enum {
#endif
}
qemudLogPriority
;
/* Different types of QEMU acceleration possible */
enum
qemud_vm_virt_type
{
QEMUD_VIRT_QEMU
,
QEMUD_VIRT_KQEMU
,
QEMUD_VIRT_KVM
,
};
/* Two types of disk backends */
enum
qemud_vm_disk_type
{
QEMUD_DISK_BLOCK
,
QEMUD_DISK_FILE
};
/* Three types of disk frontend */
enum
qemud_vm_disk_device
{
QEMUD_DISK_DISK
,
QEMUD_DISK_CDROM
,
QEMUD_DISK_FLOPPY
,
};
/* Stores the virtual disk configuration */
struct
qemud_vm_disk_def
{
int
type
;
int
device
;
char
src
[
PATH_MAX
];
char
dst
[
NAME_MAX
];
int
readonly
;
struct
qemud_vm_disk_def
*
next
;
};
#define QEMUD_MAC_ADDRESS_LEN 6
#define QEMUD_OS_TYPE_MAX_LEN 10
#define QEMUD_OS_ARCH_MAX_LEN 10
#define QEMUD_OS_MACHINE_MAX_LEN 10
/* 5 different types of networking config */
enum
qemud_vm_net_type
{
QEMUD_NET_USER
,
QEMUD_NET_ETHERNET
,
QEMUD_NET_SERVER
,
QEMUD_NET_CLIENT
,
QEMUD_NET_MCAST
,
QEMUD_NET_NETWORK
,
QEMUD_NET_BRIDGE
,
};
/* Stores the virtual network interface configuration */
struct
qemud_vm_net_def
{
int
type
;
unsigned
char
mac
[
QEMUD_MAC_ADDRESS_LEN
];
union
{
struct
{
char
ifname
[
BR_IFNAME_MAXLEN
];
char
script
[
PATH_MAX
];
}
ethernet
;
struct
{
char
address
[
BR_INET_ADDR_MAXLEN
];
int
port
;
}
socket
;
/* any of NET_CLIENT or NET_SERVER or NET_MCAST */
struct
{
char
name
[
QEMUD_MAX_NAME_LEN
];
char
ifname
[
BR_IFNAME_MAXLEN
];
}
network
;
struct
{
char
brname
[
BR_IFNAME_MAXLEN
];
char
ifname
[
BR_IFNAME_MAXLEN
];
}
bridge
;
}
dst
;
struct
qemud_vm_net_def
*
next
;
};
#define QEMUD_MAX_BOOT_DEVS 4
/* 3 possible boot devices */
enum
qemud_vm_boot_order
{
QEMUD_BOOT_FLOPPY
,
QEMUD_BOOT_CDROM
,
QEMUD_BOOT_DISK
,
QEMUD_BOOT_NET
,
};
/* 3 possible graphics console modes */
enum
qemud_vm_grapics_type
{
QEMUD_GRAPHICS_NONE
,
QEMUD_GRAPHICS_SDL
,
QEMUD_GRAPHICS_VNC
,
};
/* Internal flags to keep track of qemu command line capabilities */
enum
qemud_cmd_flags
{
QEMUD_CMD_FLAG_KQEMU
=
1
,
QEMUD_CMD_FLAG_VNC_COLON
=
2
,
QEMUD_CMD_FLAG_NO_REBOOT
=
4
,
};
enum
qemud_vm_features
{
QEMUD_FEATURE_ACPI
=
1
,
};
/* Operating system configuration data & machine / arch */
struct
qemud_vm_os_def
{
char
type
[
QEMUD_OS_TYPE_MAX_LEN
];
char
arch
[
QEMUD_OS_ARCH_MAX_LEN
];
char
machine
[
QEMUD_OS_MACHINE_MAX_LEN
];
int
nBootDevs
;
int
bootDevs
[
QEMUD_MAX_BOOT_DEVS
];
char
kernel
[
PATH_MAX
];
char
initrd
[
PATH_MAX
];
char
cmdline
[
PATH_MAX
];
char
binary
[
PATH_MAX
];
};
/* Guest VM main configuration */
struct
qemud_vm_def
{
int
virtType
;
unsigned
char
uuid
[
QEMUD_UUID_RAW_LEN
];
char
name
[
QEMUD_MAX_NAME_LEN
];
int
memory
;
int
maxmem
;
int
vcpus
;
int
noReboot
;
struct
qemud_vm_os_def
os
;
int
features
;
int
graphicsType
;
int
vncPort
;
int
vncActivePort
;
int
ndisks
;
struct
qemud_vm_disk_def
*
disks
;
int
nnets
;
struct
qemud_vm_net_def
*
nets
;
};
/* Guest VM runtime state */
struct
qemud_vm
{
int
stdout
;
int
stderr
;
int
monitor
;
int
logfile
;
int
pid
;
int
id
;
int
state
;
int
*
tapfds
;
int
ntapfds
;
char
configFile
[
PATH_MAX
];
char
autostartLink
[
PATH_MAX
];
struct
qemud_vm_def
*
def
;
/* The current definition */
struct
qemud_vm_def
*
newDef
;
/* New definition to activate at shutdown */
unsigned
int
autostart
:
1
;
struct
qemud_vm
*
next
;
};
/* Store start and end addresses of a dhcp range */
struct
qemud_dhcp_range_def
{
char
start
[
BR_INET_ADDR_MAXLEN
];
char
end
[
BR_INET_ADDR_MAXLEN
];
struct
qemud_dhcp_range_def
*
next
;
};
/* Virtual Network main configuration */
struct
qemud_network_def
{
unsigned
char
uuid
[
QEMUD_UUID_RAW_LEN
];
char
name
[
QEMUD_MAX_NAME_LEN
];
char
bridge
[
BR_IFNAME_MAXLEN
];
int
disableSTP
;
int
forwardDelay
;
int
forward
;
char
forwardDev
[
BR_IFNAME_MAXLEN
];
char
ipAddress
[
BR_INET_ADDR_MAXLEN
];
char
netmask
[
BR_INET_ADDR_MAXLEN
];
char
network
[
BR_INET_ADDR_MAXLEN
+
BR_INET_ADDR_MAXLEN
+
1
];
int
nranges
;
struct
qemud_dhcp_range_def
*
ranges
;
};
/* Virtual Network runtime state */
struct
qemud_network
{
char
configFile
[
PATH_MAX
];
char
autostartLink
[
PATH_MAX
];
struct
qemud_network_def
*
def
;
/* The current definition */
struct
qemud_network_def
*
newDef
;
/* New definition to activate at shutdown */
char
bridge
[
BR_IFNAME_MAXLEN
];
int
dnsmasqPid
;
unsigned
int
active
:
1
;
unsigned
int
autostart
:
1
;
struct
qemud_network
*
next
;
};
enum
qemud_mode
{
QEMUD_MODE_RX_HEADER
,
...
...
@@ -333,24 +123,9 @@ struct qemud_socket {
struct
qemud_server
{
int
nsockets
;
struct
qemud_socket
*
sockets
;
int
qemuVersion
;
int
qemuCmdFlags
;
/* values from enum qemud_cmd_flags */
int
nclients
;
struct
qemud_client
*
clients
;
int
sigread
;
int
nactivevms
;
int
ninactivevms
;
struct
qemud_vm
*
vms
;
int
nextvmid
;
int
nactivenetworks
;
int
ninactivenetworks
;
struct
qemud_network
*
networks
;
brControl
*
brctl
;
iptablesContext
*
iptables
;
char
*
configDir
;
char
*
autostartDir
;
char
*
networkConfigDir
;
char
*
networkAutostartDir
;
char
logDir
[
PATH_MAX
];
unsigned
int
shutdown
:
1
;
};
...
...
@@ -367,17 +142,6 @@ void qemudLog(int priority, const char *fmt, ...)
void
remoteDispatchClientRequest
(
struct
qemud_server
*
server
,
struct
qemud_client
*
client
);
static
inline
int
qemudIsActiveVM
(
struct
qemud_vm
*
vm
)
{
return
vm
->
id
!=
-
1
;
}
static
inline
int
qemudIsActiveNetwork
(
struct
qemud_network
*
network
)
{
return
network
->
active
;
}
#endif
...
...
qemud/qemud.c
浏览文件 @
b63f8cc9
...
...
@@ -207,7 +207,7 @@ static void qemudDispatchSignalEvent(int fd ATTRIBUTE_UNUSED,
case
SIGHUP
:
qemudLog
(
QEMUD_INFO
,
"Reloading configuration on SIGHUP"
);
if
(
!
remote
)
{
qemudReload
(
server
);
qemudReload
();
}
break
;
...
...
@@ -217,7 +217,7 @@ static void qemudDispatchSignalEvent(int fd ATTRIBUTE_UNUSED,
qemudLog
(
QEMUD_WARN
,
"Shutting down on signal %d"
,
sigc
);
if
(
!
remote
)
{
qemudShutdown
(
server
);
qemudShutdown
();
}
server
->
shutdown
=
1
;
...
...
@@ -620,11 +620,6 @@ static int qemudInitPaths(struct qemud_server *server,
unlink
(
roSockname
);
server
->
configDir
=
server
->
autostartDir
=
server
->
networkConfigDir
=
server
->
networkAutostartDir
=
NULL
;
if
(
snprintf
(
server
->
logDir
,
PATH_MAX
,
"%s/log/libvirt/qemu"
,
LOCAL_STATE_DIR
)
>=
PATH_MAX
)
goto
snprintf_error
;
}
else
{
...
...
@@ -660,30 +655,15 @@ static int qemudInitPaths(struct qemud_server *server,
if
(
snprintf
(
sockname
,
maxlen
,
"@%s/.libvirt/qemud-sock"
,
pw
->
pw_dir
)
>=
maxlen
)
goto
snprintf_error
;
if
(
snprintf
(
server
->
logDir
,
PATH_MAX
,
"%s/.libvirt/qemu/log"
,
pw
->
pw_dir
)
>=
PATH_MAX
)
goto
snprintf_error
;
if
(
asprintf
(
&
base
,
"%s/.libvirt/qemu"
,
pw
->
pw_dir
)
==
-
1
)
{
qemudLog
(
QEMUD_ERR
,
"out of memory in asprintf"
);
return
-
1
;
}
}
/* Configuration paths are either ~/.libvirt/qemu/... (session) or
* /etc/libvirt/qemu/... (system).
*/
if
(
asprintf
(
&
server
->
configDir
,
"%s"
,
base
)
==
-
1
)
goto
out_of_memory
;
if
(
asprintf
(
&
server
->
autostartDir
,
"%s/autostart"
,
base
)
==
-
1
)
goto
out_of_memory
;
if
(
asprintf
(
&
server
->
networkConfigDir
,
"%s/networks"
,
base
)
==
-
1
)
goto
out_of_memory
;
if
(
asprintf
(
&
server
->
networkAutostartDir
,
"%s/networks/autostart"
,
base
)
==
-
1
)
goto
out_of_memory
;
if
(
snprintf
(
server
->
logDir
,
PATH_MAX
,
"%s/log"
,
base
)
>=
PATH_MAX
)
goto
snprintf_error
;
}
/* !remote */
if
(
base
)
free
(
base
);
...
...
@@ -711,7 +691,6 @@ static struct qemud_server *qemudInitialize(int sigread) {
}
/* We don't have a dom-0, so start from 1 */
server
->
nextvmid
=
1
;
server
->
sigread
=
sigread
;
roSockname
[
0
]
=
'\0'
;
...
...
@@ -726,7 +705,7 @@ static struct qemud_server *qemudInitialize(int sigread) {
goto
cleanup
;
if
(
!
remote
)
/* qemud only */
{
if
(
qemudStartup
(
server
)
<
0
)
{
if
(
qemudStartup
()
<
0
)
{
goto
cleanup
;
}
}
else
/* remote only */
{
...
...
@@ -745,6 +724,7 @@ static struct qemud_server *qemudInitialize(int sigread) {
return
server
;
cleanup:
qemudShutdown
();
if
(
server
)
{
struct
qemud_socket
*
sock
=
server
->
sockets
;
while
(
sock
)
{
...
...
@@ -752,11 +732,6 @@ static struct qemud_server *qemudInitialize(int sigread) {
sock
=
sock
->
next
;
}
if
(
server
->
configDir
)
free
(
server
->
configDir
);
if
(
server
->
autostartDir
)
free
(
server
->
autostartDir
);
if
(
server
->
networkConfigDir
)
free
(
server
->
networkConfigDir
);
if
(
server
->
networkAutostartDir
)
free
(
server
->
networkAutostartDir
);
free
(
server
);
}
return
NULL
;
...
...
@@ -1525,15 +1500,8 @@ static void qemudCleanup(struct qemud_server *server) {
sock
=
next
;
}
if
(
server
->
brctl
)
brShutdown
(
server
->
brctl
);
if
(
server
->
iptables
)
iptablesContextFree
(
server
->
iptables
);
if
(
server
->
configDir
)
free
(
server
->
configDir
);
if
(
server
->
autostartDir
)
free
(
server
->
autostartDir
);
if
(
server
->
networkConfigDir
)
free
(
server
->
networkConfigDir
);
if
(
server
->
networkAutostartDir
)
free
(
server
->
networkAutostartDir
);
qemudShutdown
();
free
(
server
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录