Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
675ba317
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看板
提交
675ba317
编写于
6月 26, 2007
作者:
D
Daniel P. Berrange
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Rename buffer functions
上级
3d6a119d
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
129 addition
and
124 deletion
+129
-124
ChangeLog
ChangeLog
+6
-1
qemud/buf.c
qemud/buf.c
+19
-19
qemud/buf.h
qemud/buf.h
+15
-15
qemud/conf.c
qemud/conf.c
+72
-72
qemud/driver.c
qemud/driver.c
+17
-17
未找到文件。
ChangeLog
浏览文件 @
675ba317
Tue Jun 26 18:10:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
Tue Jun 26 18:21:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* qemud/conf.c, qemud/driver.c, qemud/buf.c, qemud/buf.h:
Rename the buffer functions to match those in src/ directory.
Tue Jun 26 18:18:00 EST 2007 Daniel P. Berrange <berrange@redhat.com>
* qemud/conf.c, qemud/uuid.c, qemud/uuid.h: Rename the
UUID functions to not include QEMU in name.
...
...
qemud/buf.c
浏览文件 @
675ba317
/*
* buf.c: buffers for
qemud
* buf.c: buffers for
libvirt
*
* Copyright (C) 2005 Red Hat, Inc.
* Copyright (C) 2005
-2007
Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
...
...
@@ -17,7 +17,7 @@
#include "buf.h"
/**
*
b
ufferGrow:
*
virB
ufferGrow:
* @buf: the buffer
* @len: the minimum free size to allocate on top of existing used space
*
...
...
@@ -26,7 +26,7 @@
* Returns the new available space or -1 in case of error
*/
static
int
bufferGrow
(
b
ufferPtr
buf
,
unsigned
int
len
)
virBufferGrow
(
virB
ufferPtr
buf
,
unsigned
int
len
)
{
int
size
;
char
*
newbuf
;
...
...
@@ -46,7 +46,7 @@ bufferGrow(bufferPtr buf, unsigned int len)
}
/**
*
b
ufferAdd:
*
virB
ufferAdd:
* @buf: the buffer to dump
* @str: the string
* @len: the number of bytes to add
...
...
@@ -57,7 +57,7 @@ bufferGrow(bufferPtr buf, unsigned int len)
* Returns 0 successful, -1 in case of internal or API error.
*/
int
bufferAdd
(
b
ufferPtr
buf
,
const
char
*
str
,
int
len
)
virBufferAdd
(
virB
ufferPtr
buf
,
const
char
*
str
,
int
len
)
{
unsigned
int
needSize
;
...
...
@@ -72,7 +72,7 @@ bufferAdd(bufferPtr buf, const char *str, int len)
needSize
=
buf
->
use
+
len
+
2
;
if
(
needSize
>
buf
->
size
)
{
if
(
!
b
ufferGrow
(
buf
,
needSize
-
buf
->
use
))
{
if
(
!
virB
ufferGrow
(
buf
,
needSize
-
buf
->
use
))
{
return
(
-
1
);
}
}
...
...
@@ -83,10 +83,10 @@ bufferAdd(bufferPtr buf, const char *str, int len)
return
(
0
);
}
b
ufferPtr
b
ufferNew
(
unsigned
int
size
)
virB
ufferPtr
virB
ufferNew
(
unsigned
int
size
)
{
b
ufferPtr
buf
;
virB
ufferPtr
buf
;
if
(
!
(
buf
=
malloc
(
sizeof
(
*
buf
))))
return
NULL
;
if
(
size
&&
(
buf
->
content
=
malloc
(
size
))
==
NULL
)
{
...
...
@@ -100,7 +100,7 @@ bufferNew(unsigned int size)
}
void
bufferFree
(
b
ufferPtr
buf
)
virBufferFree
(
virB
ufferPtr
buf
)
{
if
(
buf
)
{
if
(
buf
->
content
)
...
...
@@ -110,13 +110,13 @@ bufferFree(bufferPtr buf)
}
/**
*
b
ufferContentAndFree:
*
virB
ufferContentAndFree:
* @buf: Buffer
*
* Return the content from the buffer and free (only) the buffer structure.
*/
char
*
bufferContentAndFree
(
b
ufferPtr
buf
)
virBufferContentAndFree
(
virB
ufferPtr
buf
)
{
char
*
content
=
buf
->
content
;
...
...
@@ -125,7 +125,7 @@ bufferContentAndFree (bufferPtr buf)
}
/**
*
b
ufferVSprintf:
*
virB
ufferVSprintf:
* @buf: the buffer to dump
* @format: the format
* @argptr: the variable list of arguments
...
...
@@ -135,7 +135,7 @@ bufferContentAndFree (bufferPtr buf)
* Returns 0 successful, -1 in case of internal or API error.
*/
int
bufferVSprintf
(
b
ufferPtr
buf
,
const
char
*
format
,
...)
virBufferVSprintf
(
virB
ufferPtr
buf
,
const
char
*
format
,
...)
{
int
size
,
count
;
va_list
locarg
,
argptr
;
...
...
@@ -150,7 +150,7 @@ bufferVSprintf(bufferPtr buf, const char *format, ...)
locarg
))
<
0
)
||
(
count
>=
size
-
1
))
{
buf
->
content
[
buf
->
use
]
=
0
;
va_end
(
locarg
);
if
(
b
ufferGrow
(
buf
,
1000
)
<
0
)
{
if
(
virB
ufferGrow
(
buf
,
1000
)
<
0
)
{
return
(
-
1
);
}
size
=
buf
->
size
-
buf
->
use
-
1
;
...
...
@@ -163,7 +163,7 @@ bufferVSprintf(bufferPtr buf, const char *format, ...)
}
/**
*
b
ufferStrcat:
*
virB
ufferStrcat:
* @buf: the buffer to dump
* @argptr: the variable list of strings, the last argument must be NULL
*
...
...
@@ -172,7 +172,7 @@ bufferVSprintf(bufferPtr buf, const char *format, ...)
* Returns 0 successful, -1 in case of internal or API error.
*/
int
bufferStrcat
(
b
ufferPtr
buf
,
...)
virBufferStrcat
(
virB
ufferPtr
buf
,
...)
{
va_list
ap
;
char
*
str
;
...
...
@@ -184,7 +184,7 @@ bufferStrcat(bufferPtr buf, ...)
unsigned
int
needSize
=
buf
->
use
+
len
+
2
;
if
(
needSize
>
buf
->
size
)
{
if
(
!
b
ufferGrow
(
buf
,
needSize
-
buf
->
use
))
if
(
!
virB
ufferGrow
(
buf
,
needSize
-
buf
->
use
))
return
-
1
;
}
memcpy
(
&
buf
->
content
[
buf
->
use
],
str
,
len
);
...
...
qemud/buf.h
浏览文件 @
675ba317
/*
* buf.h: buffers for
qemud
* buf.h: buffers for
libvirt
*
* Copyright (C) 2005 Red Hat, Inc.
* Copyright (C) 2005
-2007
Red Hat, Inc.
*
* See COPYING.LIB for the License of this software
*
* Daniel Veillard <veillard@redhat.com>
*/
#ifndef __
QEMUD_BUF
_H__
#define __
QEMUD_BUF
_H__
#ifndef __
VIR_BUFFER
_H__
#define __
VIR_BUFFER
_H__
#include "internal.h"
/**
*
b
uffer:
*
virB
uffer:
*
* A buffer structure.
*/
typedef
struct
_
buffer
b
uffer
;
typedef
buffer
*
b
ufferPtr
;
struct
_
b
uffer
{
typedef
struct
_
virBuffer
virB
uffer
;
typedef
virBuffer
*
virB
ufferPtr
;
struct
_
virB
uffer
{
char
*
content
;
/* The buffer content UTF8 */
unsigned
int
use
;
/* The buffer size used */
unsigned
int
size
;
/* The buffer size */
};
bufferPtr
b
ufferNew
(
unsigned
int
size
);
void
bufferFree
(
b
ufferPtr
buf
);
char
*
bufferContentAndFree
(
b
ufferPtr
buf
);
int
bufferAdd
(
b
ufferPtr
buf
,
const
char
*
str
,
int
len
);
int
bufferVSprintf
(
b
ufferPtr
buf
,
const
char
*
format
,
...)
virBufferPtr
virB
ufferNew
(
unsigned
int
size
);
void
virBufferFree
(
virB
ufferPtr
buf
);
char
*
virBufferContentAndFree
(
virB
ufferPtr
buf
);
int
virBufferAdd
(
virB
ufferPtr
buf
,
const
char
*
str
,
int
len
);
int
virBufferVSprintf
(
virB
ufferPtr
buf
,
const
char
*
format
,
...)
ATTRIBUTE_FORMAT
(
printf
,
2
,
3
);
int
bufferStrcat
(
b
ufferPtr
buf
,
...);
int
virBufferStrcat
(
virB
ufferPtr
buf
,
...);
#endif
/* __QEMUD_BUF
_H__ */
#endif
/* __VIR_BUFFER
_H__ */
qemud/conf.c
浏览文件 @
675ba317
...
...
@@ -2446,14 +2446,14 @@ char *qemudGenerateXML(struct qemud_driver *driver,
struct
qemud_vm
*
vm
,
struct
qemud_vm_def
*
def
,
int
live
)
{
b
ufferPtr
buf
=
0
;
virB
ufferPtr
buf
=
0
;
unsigned
char
*
uuid
;
struct
qemud_vm_disk_def
*
disk
;
struct
qemud_vm_net_def
*
net
;
const
char
*
type
=
NULL
;
int
n
;
buf
=
b
ufferNew
(
QEMUD_MAX_XML_LEN
);
buf
=
virB
ufferNew
(
QEMUD_MAX_XML_LEN
);
if
(
!
buf
)
goto
no_memory
;
...
...
@@ -2474,50 +2474,50 @@ char *qemudGenerateXML(struct qemud_driver *driver,
}
if
(
qemudIsActiveVM
(
vm
)
&&
live
)
{
if
(
b
ufferVSprintf
(
buf
,
"<domain type='%s' id='%d'>
\n
"
,
type
,
vm
->
id
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
"<domain type='%s' id='%d'>
\n
"
,
type
,
vm
->
id
)
<
0
)
goto
no_memory
;
}
else
{
if
(
b
ufferVSprintf
(
buf
,
"<domain type='%s'>
\n
"
,
type
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
"<domain type='%s'>
\n
"
,
type
)
<
0
)
goto
no_memory
;
}
if
(
b
ufferVSprintf
(
buf
,
" <name>%s</name>
\n
"
,
def
->
name
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
" <name>%s</name>
\n
"
,
def
->
name
)
<
0
)
goto
no_memory
;
uuid
=
def
->
uuid
;
if
(
b
ufferVSprintf
(
buf
,
" <uuid>%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x</uuid>
\n
"
,
if
(
virB
ufferVSprintf
(
buf
,
" <uuid>%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x</uuid>
\n
"
,
uuid
[
0
],
uuid
[
1
],
uuid
[
2
],
uuid
[
3
],
uuid
[
4
],
uuid
[
5
],
uuid
[
6
],
uuid
[
7
],
uuid
[
8
],
uuid
[
9
],
uuid
[
10
],
uuid
[
11
],
uuid
[
12
],
uuid
[
13
],
uuid
[
14
],
uuid
[
15
])
<
0
)
goto
no_memory
;
if
(
b
ufferVSprintf
(
buf
,
" <memory>%d</memory>
\n
"
,
def
->
maxmem
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
" <memory>%d</memory>
\n
"
,
def
->
maxmem
)
<
0
)
goto
no_memory
;
if
(
b
ufferVSprintf
(
buf
,
" <currentMemory>%d</currentMemory>
\n
"
,
def
->
memory
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
" <currentMemory>%d</currentMemory>
\n
"
,
def
->
memory
)
<
0
)
goto
no_memory
;
if
(
b
ufferVSprintf
(
buf
,
" <vcpu>%d</vcpu>
\n
"
,
def
->
vcpus
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
" <vcpu>%d</vcpu>
\n
"
,
def
->
vcpus
)
<
0
)
goto
no_memory
;
if
(
b
ufferAdd
(
buf
,
" <os>
\n
"
,
-
1
)
<
0
)
if
(
virB
ufferAdd
(
buf
,
" <os>
\n
"
,
-
1
)
<
0
)
goto
no_memory
;
if
(
def
->
virtType
==
QEMUD_VIRT_QEMU
)
{
if
(
b
ufferVSprintf
(
buf
,
" <type arch='%s' machine='%s'>%s</type>
\n
"
,
if
(
virB
ufferVSprintf
(
buf
,
" <type arch='%s' machine='%s'>%s</type>
\n
"
,
def
->
os
.
arch
,
def
->
os
.
machine
,
def
->
os
.
type
)
<
0
)
goto
no_memory
;
}
else
{
if
(
b
ufferVSprintf
(
buf
,
" <type>%s</type>
\n
"
,
def
->
os
.
type
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
" <type>%s</type>
\n
"
,
def
->
os
.
type
)
<
0
)
goto
no_memory
;
}
if
(
def
->
os
.
kernel
[
0
])
if
(
b
ufferVSprintf
(
buf
,
" <kernel>%s</kernel>
\n
"
,
def
->
os
.
kernel
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
" <kernel>%s</kernel>
\n
"
,
def
->
os
.
kernel
)
<
0
)
goto
no_memory
;
if
(
def
->
os
.
initrd
[
0
])
if
(
b
ufferVSprintf
(
buf
,
" <initrd>%s</initrd>
\n
"
,
def
->
os
.
initrd
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
" <initrd>%s</initrd>
\n
"
,
def
->
os
.
initrd
)
<
0
)
goto
no_memory
;
if
(
def
->
os
.
cmdline
[
0
])
if
(
b
ufferVSprintf
(
buf
,
" <cmdline>%s</cmdline>
\n
"
,
def
->
os
.
cmdline
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
" <cmdline>%s</cmdline>
\n
"
,
def
->
os
.
cmdline
)
<
0
)
goto
no_memory
;
for
(
n
=
0
;
n
<
def
->
os
.
nBootDevs
;
n
++
)
{
...
...
@@ -2536,38 +2536,38 @@ char *qemudGenerateXML(struct qemud_driver *driver,
boottype
=
"net"
;
break
;
}
if
(
b
ufferVSprintf
(
buf
,
" <boot dev='%s'/>
\n
"
,
boottype
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
" <boot dev='%s'/>
\n
"
,
boottype
)
<
0
)
goto
no_memory
;
}
if
(
b
ufferAdd
(
buf
,
" </os>
\n
"
,
-
1
)
<
0
)
if
(
virB
ufferAdd
(
buf
,
" </os>
\n
"
,
-
1
)
<
0
)
goto
no_memory
;
if
(
def
->
features
&
QEMUD_FEATURE_ACPI
)
{
if
(
b
ufferAdd
(
buf
,
" <features>
\n
"
,
-
1
)
<
0
)
if
(
virB
ufferAdd
(
buf
,
" <features>
\n
"
,
-
1
)
<
0
)
goto
no_memory
;
if
(
b
ufferAdd
(
buf
,
" <acpi/>
\n
"
,
-
1
)
<
0
)
if
(
virB
ufferAdd
(
buf
,
" <acpi/>
\n
"
,
-
1
)
<
0
)
goto
no_memory
;
if
(
b
ufferAdd
(
buf
,
" </features>
\n
"
,
-
1
)
<
0
)
if
(
virB
ufferAdd
(
buf
,
" </features>
\n
"
,
-
1
)
<
0
)
goto
no_memory
;
}
if
(
b
ufferAdd
(
buf
,
" <on_poweroff>destroy</on_poweroff>
\n
"
,
-
1
)
<
0
)
if
(
virB
ufferAdd
(
buf
,
" <on_poweroff>destroy</on_poweroff>
\n
"
,
-
1
)
<
0
)
goto
no_memory
;
if
(
def
->
noReboot
)
{
if
(
b
ufferAdd
(
buf
,
" <on_reboot>destroy</on_reboot>
\n
"
,
-
1
)
<
0
)
if
(
virB
ufferAdd
(
buf
,
" <on_reboot>destroy</on_reboot>
\n
"
,
-
1
)
<
0
)
goto
no_memory
;
}
else
{
if
(
b
ufferAdd
(
buf
,
" <on_reboot>restart</on_reboot>
\n
"
,
-
1
)
<
0
)
if
(
virB
ufferAdd
(
buf
,
" <on_reboot>restart</on_reboot>
\n
"
,
-
1
)
<
0
)
goto
no_memory
;
}
if
(
b
ufferAdd
(
buf
,
" <on_crash>destroy</on_crash>
\n
"
,
-
1
)
<
0
)
if
(
virB
ufferAdd
(
buf
,
" <on_crash>destroy</on_crash>
\n
"
,
-
1
)
<
0
)
goto
no_memory
;
if
(
b
ufferAdd
(
buf
,
" <devices>
\n
"
,
-
1
)
<
0
)
if
(
virB
ufferAdd
(
buf
,
" <devices>
\n
"
,
-
1
)
<
0
)
goto
no_memory
;
if
(
b
ufferVSprintf
(
buf
,
" <emulator>%s</emulator>
\n
"
,
def
->
os
.
binary
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
" <emulator>%s</emulator>
\n
"
,
def
->
os
.
binary
)
<
0
)
goto
no_memory
;
disk
=
def
->
disks
;
...
...
@@ -2585,21 +2585,21 @@ char *qemudGenerateXML(struct qemud_driver *driver,
"cdrom"
,
"floppy"
,
};
if
(
b
ufferVSprintf
(
buf
,
" <disk type='%s' device='%s'>
\n
"
,
if
(
virB
ufferVSprintf
(
buf
,
" <disk type='%s' device='%s'>
\n
"
,
types
[
disk
->
type
],
devices
[
disk
->
device
])
<
0
)
goto
no_memory
;
if
(
b
ufferVSprintf
(
buf
,
" <source %s='%s'/>
\n
"
,
typeAttrs
[
disk
->
type
],
disk
->
src
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
" <source %s='%s'/>
\n
"
,
typeAttrs
[
disk
->
type
],
disk
->
src
)
<
0
)
goto
no_memory
;
if
(
b
ufferVSprintf
(
buf
,
" <target dev='%s'/>
\n
"
,
disk
->
dst
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
" <target dev='%s'/>
\n
"
,
disk
->
dst
)
<
0
)
goto
no_memory
;
if
(
disk
->
readonly
)
if
(
b
ufferAdd
(
buf
,
" <readonly/>
\n
"
,
-
1
)
<
0
)
if
(
virB
ufferAdd
(
buf
,
" <readonly/>
\n
"
,
-
1
)
<
0
)
goto
no_memory
;
if
(
b
ufferVSprintf
(
buf
,
" </disk>
\n
"
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
" </disk>
\n
"
)
<
0
)
goto
no_memory
;
disk
=
disk
->
next
;
...
...
@@ -2616,42 +2616,42 @@ char *qemudGenerateXML(struct qemud_driver *driver,
"network"
,
"bridge"
,
};
if
(
b
ufferVSprintf
(
buf
,
" <interface type='%s'>
\n
"
,
if
(
virB
ufferVSprintf
(
buf
,
" <interface type='%s'>
\n
"
,
types
[
net
->
type
])
<
0
)
goto
no_memory
;
if
(
b
ufferVSprintf
(
buf
,
" <mac address='%02x:%02x:%02x:%02x:%02x:%02x'/>
\n
"
,
if
(
virB
ufferVSprintf
(
buf
,
" <mac address='%02x:%02x:%02x:%02x:%02x:%02x'/>
\n
"
,
net
->
mac
[
0
],
net
->
mac
[
1
],
net
->
mac
[
2
],
net
->
mac
[
3
],
net
->
mac
[
4
],
net
->
mac
[
5
])
<
0
)
goto
no_memory
;
switch
(
net
->
type
)
{
case
QEMUD_NET_NETWORK
:
if
(
b
ufferVSprintf
(
buf
,
" <source network='%s'/>
\n
"
,
net
->
dst
.
network
.
name
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
" <source network='%s'/>
\n
"
,
net
->
dst
.
network
.
name
)
<
0
)
goto
no_memory
;
if
(
net
->
dst
.
network
.
ifname
[
0
]
!=
'\0'
)
{
if
(
b
ufferVSprintf
(
buf
,
" <target dev='%s'/>
\n
"
,
net
->
dst
.
network
.
ifname
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
" <target dev='%s'/>
\n
"
,
net
->
dst
.
network
.
ifname
)
<
0
)
goto
no_memory
;
}
break
;
case
QEMUD_NET_ETHERNET
:
if
(
net
->
dst
.
ethernet
.
ifname
[
0
]
!=
'\0'
)
{
if
(
b
ufferVSprintf
(
buf
,
" <target dev='%s'/>
\n
"
,
net
->
dst
.
ethernet
.
ifname
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
" <target dev='%s'/>
\n
"
,
net
->
dst
.
ethernet
.
ifname
)
<
0
)
goto
no_memory
;
}
if
(
net
->
dst
.
ethernet
.
script
[
0
]
!=
'\0'
)
{
if
(
b
ufferVSprintf
(
buf
,
" <script path='%s'/>
\n
"
,
net
->
dst
.
ethernet
.
script
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
" <script path='%s'/>
\n
"
,
net
->
dst
.
ethernet
.
script
)
<
0
)
goto
no_memory
;
}
break
;
case
QEMUD_NET_BRIDGE
:
if
(
b
ufferVSprintf
(
buf
,
" <source bridge='%s'/>
\n
"
,
net
->
dst
.
bridge
.
brname
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
" <source bridge='%s'/>
\n
"
,
net
->
dst
.
bridge
.
brname
)
<
0
)
goto
no_memory
;
if
(
net
->
dst
.
bridge
.
ifname
[
0
]
!=
'\0'
)
{
if
(
b
ufferVSprintf
(
buf
,
" <target dev='%s'/>
\n
"
,
net
->
dst
.
bridge
.
ifname
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
" <target dev='%s'/>
\n
"
,
net
->
dst
.
bridge
.
ifname
)
<
0
)
goto
no_memory
;
}
break
;
...
...
@@ -2660,17 +2660,17 @@ char *qemudGenerateXML(struct qemud_driver *driver,
case
QEMUD_NET_CLIENT
:
case
QEMUD_NET_MCAST
:
if
(
net
->
dst
.
socket
.
address
[
0
]
!=
'\0'
)
{
if
(
b
ufferVSprintf
(
buf
,
" <source address='%s' port='%d'/>
\n
"
,
if
(
virB
ufferVSprintf
(
buf
,
" <source address='%s' port='%d'/>
\n
"
,
net
->
dst
.
socket
.
address
,
net
->
dst
.
socket
.
port
)
<
0
)
goto
no_memory
;
}
else
{
if
(
b
ufferVSprintf
(
buf
,
" <source port='%d'/>
\n
"
,
if
(
virB
ufferVSprintf
(
buf
,
" <source port='%d'/>
\n
"
,
net
->
dst
.
socket
.
port
)
<
0
)
goto
no_memory
;
}
}
if
(
b
ufferVSprintf
(
buf
,
" </interface>
\n
"
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
" </interface>
\n
"
)
<
0
)
goto
no_memory
;
net
=
net
->
next
;
...
...
@@ -2678,20 +2678,20 @@ char *qemudGenerateXML(struct qemud_driver *driver,
switch
(
def
->
graphicsType
)
{
case
QEMUD_GRAPHICS_VNC
:
if
(
b
ufferAdd
(
buf
,
" <graphics type='vnc'"
,
-
1
)
<
0
)
if
(
virB
ufferAdd
(
buf
,
" <graphics type='vnc'"
,
-
1
)
<
0
)
goto
no_memory
;
if
(
def
->
vncPort
&&
b
ufferVSprintf
(
buf
,
" port='%d'"
,
virB
ufferVSprintf
(
buf
,
" port='%d'"
,
qemudIsActiveVM
(
vm
)
&&
live
?
def
->
vncActivePort
:
def
->
vncPort
)
<
0
)
goto
no_memory
;
if
(
b
ufferAdd
(
buf
,
"/>
\n
"
,
-
1
)
<
0
)
if
(
virB
ufferAdd
(
buf
,
"/>
\n
"
,
-
1
)
<
0
)
goto
no_memory
;
break
;
case
QEMUD_GRAPHICS_SDL
:
if
(
b
ufferAdd
(
buf
,
" <graphics type='sdl'/>
\n
"
,
-
1
)
<
0
)
if
(
virB
ufferAdd
(
buf
,
" <graphics type='sdl'/>
\n
"
,
-
1
)
<
0
)
goto
no_memory
;
break
;
...
...
@@ -2703,19 +2703,19 @@ char *qemudGenerateXML(struct qemud_driver *driver,
if
(
def
->
graphicsType
==
QEMUD_GRAPHICS_VNC
)
{
}
if
(
b
ufferAdd
(
buf
,
" </devices>
\n
"
,
-
1
)
<
0
)
if
(
virB
ufferAdd
(
buf
,
" </devices>
\n
"
,
-
1
)
<
0
)
goto
no_memory
;
if
(
b
ufferAdd
(
buf
,
"</domain>
\n
"
,
-
1
)
<
0
)
if
(
virB
ufferAdd
(
buf
,
"</domain>
\n
"
,
-
1
)
<
0
)
goto
no_memory
;
return
b
ufferContentAndFree
(
buf
);
return
virB
ufferContentAndFree
(
buf
);
no_memory:
qemudReportError
(
NULL
,
NULL
,
NULL
,
VIR_ERR_NO_MEMORY
,
"xml"
);
cleanup:
if
(
buf
)
b
ufferFree
(
buf
);
if
(
buf
)
virB
ufferFree
(
buf
);
return
NULL
;
}
...
...
@@ -2723,21 +2723,21 @@ char *qemudGenerateXML(struct qemud_driver *driver,
char
*
qemudGenerateNetworkXML
(
struct
qemud_driver
*
driver
,
struct
qemud_network
*
network
,
struct
qemud_network_def
*
def
)
{
b
ufferPtr
buf
=
0
;
virB
ufferPtr
buf
=
0
;
unsigned
char
*
uuid
;
buf
=
b
ufferNew
(
QEMUD_MAX_XML_LEN
);
buf
=
virB
ufferNew
(
QEMUD_MAX_XML_LEN
);
if
(
!
buf
)
goto
no_memory
;
if
(
b
ufferVSprintf
(
buf
,
"<network>
\n
"
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
"<network>
\n
"
)
<
0
)
goto
no_memory
;
if
(
b
ufferVSprintf
(
buf
,
" <name>%s</name>
\n
"
,
def
->
name
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
" <name>%s</name>
\n
"
,
def
->
name
)
<
0
)
goto
no_memory
;
uuid
=
def
->
uuid
;
if
(
b
ufferVSprintf
(
buf
,
" <uuid>%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x</uuid>
\n
"
,
if
(
virB
ufferVSprintf
(
buf
,
" <uuid>%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x</uuid>
\n
"
,
uuid
[
0
],
uuid
[
1
],
uuid
[
2
],
uuid
[
3
],
uuid
[
4
],
uuid
[
5
],
uuid
[
6
],
uuid
[
7
],
uuid
[
8
],
uuid
[
9
],
uuid
[
10
],
uuid
[
11
],
...
...
@@ -2746,67 +2746,67 @@ char *qemudGenerateNetworkXML(struct qemud_driver *driver,
if
(
def
->
forward
)
{
if
(
def
->
forwardDev
[
0
])
{
b
ufferVSprintf
(
buf
,
" <forward dev='%s'/>
\n
"
,
virB
ufferVSprintf
(
buf
,
" <forward dev='%s'/>
\n
"
,
def
->
forwardDev
);
}
else
{
b
ufferAdd
(
buf
,
" <forward/>
\n
"
,
-
1
);
virB
ufferAdd
(
buf
,
" <forward/>
\n
"
,
-
1
);
}
}
b
ufferAdd
(
buf
,
" <bridge"
,
-
1
);
virB
ufferAdd
(
buf
,
" <bridge"
,
-
1
);
if
(
qemudIsActiveNetwork
(
network
))
{
if
(
b
ufferVSprintf
(
buf
,
" name='%s'"
,
network
->
bridge
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
" name='%s'"
,
network
->
bridge
)
<
0
)
goto
no_memory
;
}
else
if
(
def
->
bridge
[
0
])
{
if
(
b
ufferVSprintf
(
buf
,
" name='%s'"
,
def
->
bridge
)
<
0
)
if
(
virB
ufferVSprintf
(
buf
,
" name='%s'"
,
def
->
bridge
)
<
0
)
goto
no_memory
;
}
if
(
b
ufferVSprintf
(
buf
,
" stp='%s' forwardDelay='%d' />
\n
"
,
if
(
virB
ufferVSprintf
(
buf
,
" stp='%s' forwardDelay='%d' />
\n
"
,
def
->
disableSTP
?
"off"
:
"on"
,
def
->
forwardDelay
)
<
0
)
goto
no_memory
;
if
(
def
->
ipAddress
[
0
]
||
def
->
netmask
[
0
])
{
if
(
b
ufferAdd
(
buf
,
" <ip"
,
-
1
)
<
0
)
if
(
virB
ufferAdd
(
buf
,
" <ip"
,
-
1
)
<
0
)
goto
no_memory
;
if
(
def
->
ipAddress
[
0
]
&&
b
ufferVSprintf
(
buf
,
" address='%s'"
,
def
->
ipAddress
)
<
0
)
virB
ufferVSprintf
(
buf
,
" address='%s'"
,
def
->
ipAddress
)
<
0
)
goto
no_memory
;
if
(
def
->
netmask
[
0
]
&&
b
ufferVSprintf
(
buf
,
" netmask='%s'"
,
def
->
netmask
)
<
0
)
virB
ufferVSprintf
(
buf
,
" netmask='%s'"
,
def
->
netmask
)
<
0
)
goto
no_memory
;
if
(
b
ufferAdd
(
buf
,
">
\n
"
,
-
1
)
<
0
)
if
(
virB
ufferAdd
(
buf
,
">
\n
"
,
-
1
)
<
0
)
goto
no_memory
;
if
(
def
->
ranges
)
{
struct
qemud_dhcp_range_def
*
range
=
def
->
ranges
;
if
(
b
ufferAdd
(
buf
,
" <dhcp>
\n
"
,
-
1
)
<
0
)
if
(
virB
ufferAdd
(
buf
,
" <dhcp>
\n
"
,
-
1
)
<
0
)
goto
no_memory
;
while
(
range
)
{
if
(
b
ufferVSprintf
(
buf
,
" <range start='%s' end='%s' />
\n
"
,
if
(
virB
ufferVSprintf
(
buf
,
" <range start='%s' end='%s' />
\n
"
,
range
->
start
,
range
->
end
)
<
0
)
goto
no_memory
;
range
=
range
->
next
;
}
if
(
b
ufferAdd
(
buf
,
" </dhcp>
\n
"
,
-
1
)
<
0
)
if
(
virB
ufferAdd
(
buf
,
" </dhcp>
\n
"
,
-
1
)
<
0
)
goto
no_memory
;
}
if
(
b
ufferAdd
(
buf
,
" </ip>
\n
"
,
-
1
)
<
0
)
if
(
virB
ufferAdd
(
buf
,
" </ip>
\n
"
,
-
1
)
<
0
)
goto
no_memory
;
}
if
(
b
ufferAdd
(
buf
,
"</network>
\n
"
,
-
1
)
<
0
)
if
(
virB
ufferAdd
(
buf
,
"</network>
\n
"
,
-
1
)
<
0
)
goto
no_memory
;
return
b
ufferContentAndFree
(
buf
);
return
virB
ufferContentAndFree
(
buf
);
no_memory:
qemudReportError
(
NULL
,
NULL
,
NULL
,
VIR_ERR_NO_MEMORY
,
"xml"
);
if
(
buf
)
b
ufferFree
(
buf
);
if
(
buf
)
virB
ufferFree
(
buf
);
return
NULL
;
}
...
...
qemud/driver.c
浏览文件 @
675ba317
...
...
@@ -1431,7 +1431,7 @@ char *qemudGetCapabilities(struct qemud_driver *driver ATTRIBUTE_UNUSED) {
int
i
,
j
,
r
;
int
have_kqemu
=
0
;
int
have_kvm
=
0
;
b
ufferPtr
xml
;
virB
ufferPtr
xml
;
/* Really, this never fails - look at the man-page. */
uname
(
&
utsname
);
...
...
@@ -1440,13 +1440,13 @@ char *qemudGetCapabilities(struct qemud_driver *driver ATTRIBUTE_UNUSED) {
have_kvm
=
access
(
"/dev/kvm"
,
F_OK
)
==
0
;
/* Construct the XML. */
xml
=
b
ufferNew
(
1024
);
xml
=
virB
ufferNew
(
1024
);
if
(
!
xml
)
{
qemudReportError
(
NULL
,
NULL
,
NULL
,
VIR_ERR_NO_MEMORY
,
NULL
);
return
NULL
;
}
r
=
b
ufferVSprintf
(
xml
,
r
=
virB
ufferVSprintf
(
xml
,
"\
<capabilities>
\n
\
<host>
\n
\
...
...
@@ -1457,7 +1457,7 @@ char *qemudGetCapabilities(struct qemud_driver *driver ATTRIBUTE_UNUSED) {
utsname
.
machine
);
if
(
r
==
-
1
)
{
vir_buffer_failed:
b
ufferFree
(
xml
);
virB
ufferFree
(
xml
);
qemudReportError
(
NULL
,
NULL
,
NULL
,
VIR_ERR_NO_MEMORY
,
NULL
);
return
NULL
;
}
...
...
@@ -1467,7 +1467,7 @@ char *qemudGetCapabilities(struct qemud_driver *driver ATTRIBUTE_UNUSED) {
else
if
(
strcmp
(
utsname
.
machine
,
"x86_64"
)
==
0
)
i
=
1
;
if
(
i
>=
0
)
{
/* For the default (PC-like) guest, qemudArchs[0] or [1]. */
r
=
b
ufferVSprintf
(
xml
,
r
=
virB
ufferVSprintf
(
xml
,
"\
\n
\
<guest>
\n
\
...
...
@@ -1482,7 +1482,7 @@ char *qemudGetCapabilities(struct qemud_driver *driver ATTRIBUTE_UNUSED) {
if
(
r
==
-
1
)
goto
vir_buffer_failed
;
for
(
j
=
0
;
qemudArchs
[
i
].
machines
[
j
];
++
j
)
{
r
=
b
ufferVSprintf
(
xml
,
r
=
virB
ufferVSprintf
(
xml
,
"\
<machine>%s</machine>
\n
"
,
qemudArchs
[
i
].
machines
[
j
]);
...
...
@@ -1490,20 +1490,20 @@ char *qemudGetCapabilities(struct qemud_driver *driver ATTRIBUTE_UNUSED) {
}
if
(
have_kqemu
)
{
r
=
b
ufferAdd
(
xml
,
r
=
virB
ufferAdd
(
xml
,
"\
<domain type=
\"
kqemu
\"
/>
\n
"
,
-
1
);
if
(
r
==
-
1
)
goto
vir_buffer_failed
;
}
if
(
have_kvm
)
{
r
=
b
ufferAdd
(
xml
,
r
=
virB
ufferAdd
(
xml
,
"\
<domain type=
\"
kvm
\"
>
\n
\
<emulator>/usr/bin/qemu-kvm</emulator>
\n
\
</domain>
\n
"
,
-
1
);
if
(
r
==
-
1
)
goto
vir_buffer_failed
;
}
r
=
b
ufferAdd
(
xml
,
r
=
virB
ufferAdd
(
xml
,
"\
</arch>
\n
\
</guest>
\n
"
,
-
1
);
...
...
@@ -1511,7 +1511,7 @@ char *qemudGetCapabilities(struct qemud_driver *driver ATTRIBUTE_UNUSED) {
/* The "other" PC architecture needs emulation. */
i
=
i
^
1
;
r
=
b
ufferVSprintf
(
xml
,
r
=
virB
ufferVSprintf
(
xml
,
"\
\n
\
<guest>
\n
\
...
...
@@ -1525,13 +1525,13 @@ char *qemudGetCapabilities(struct qemud_driver *driver ATTRIBUTE_UNUSED) {
qemudArchs
[
i
].
binary
);
if
(
r
==
-
1
)
goto
vir_buffer_failed
;
for
(
j
=
0
;
qemudArchs
[
i
].
machines
[
j
];
++
j
)
{
r
=
b
ufferVSprintf
(
xml
,
r
=
virB
ufferVSprintf
(
xml
,
"\
<machine>%s</machine>
\n
"
,
qemudArchs
[
i
].
machines
[
j
]);
if
(
r
==
-
1
)
goto
vir_buffer_failed
;
}
r
=
b
ufferAdd
(
xml
,
r
=
virB
ufferAdd
(
xml
,
"\
</arch>
\n
\
</guest>
\n
"
,
-
1
);
...
...
@@ -1540,7 +1540,7 @@ char *qemudGetCapabilities(struct qemud_driver *driver ATTRIBUTE_UNUSED) {
/* The non-PC architectures, qemudArchs[>=2]. */
for
(
i
=
2
;
qemudArchs
[
i
].
arch
;
++
i
)
{
r
=
b
ufferVSprintf
(
xml
,
r
=
virB
ufferVSprintf
(
xml
,
"\
\n
\
<guest>
\n
\
...
...
@@ -1554,13 +1554,13 @@ char *qemudGetCapabilities(struct qemud_driver *driver ATTRIBUTE_UNUSED) {
qemudArchs
[
i
].
binary
);
if
(
r
==
-
1
)
goto
vir_buffer_failed
;
for
(
j
=
0
;
qemudArchs
[
i
].
machines
[
j
];
++
j
)
{
r
=
b
ufferVSprintf
(
xml
,
r
=
virB
ufferVSprintf
(
xml
,
"\
<machine>%s</machine>
\n
"
,
qemudArchs
[
i
].
machines
[
j
]);
if
(
r
==
-
1
)
goto
vir_buffer_failed
;
}
r
=
b
ufferAdd
(
xml
,
r
=
virB
ufferAdd
(
xml
,
"\
</arch>
\n
\
</guest>
\n
"
,
-
1
);
...
...
@@ -1568,12 +1568,12 @@ char *qemudGetCapabilities(struct qemud_driver *driver ATTRIBUTE_UNUSED) {
}
/* Finish off. */
r
=
b
ufferAdd
(
xml
,
r
=
virB
ufferAdd
(
xml
,
"\
</capabilities>
\n
"
,
-
1
);
if
(
r
==
-
1
)
goto
vir_buffer_failed
;
return
b
ufferContentAndFree
(
xml
);
return
virB
ufferContentAndFree
(
xml
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录