Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
openeuler
libvirt
提交
7b934468
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看板
提交
7b934468
编写于
10月 17, 2008
作者:
D
Daniel Veillard
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
* src/qemu_driver.c: add scsi/virtio hotplug support for KVM
patch by Guido Günther daniel
上级
444efaa4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
96 addition
and
9 deletion
+96
-9
ChangeLog
ChangeLog
+5
-0
src/qemu_driver.c
src/qemu_driver.c
+91
-9
未找到文件。
ChangeLog
浏览文件 @
7b934468
Fri Oct 17 14:30:48 CEST 2008 Daniel Veillard <veillard@redhat.com>
* src/qemu_driver.c: add scsi/virtio hotplug support for KVM
patch by Guido Günther
Fri Oct 17 11:58:31 +0200 Jim Meyering <meyering@redhat.com>
Makefile.maint (sync-vcs-ignore-files): avoid risk of abuse
...
...
src/qemu_driver.c
浏览文件 @
7b934468
...
...
@@ -2509,6 +2509,75 @@ static int qemudDomainChangeEjectableMedia(virDomainPtr dom,
return
0
;
}
static
int
qemudDomainAttachDiskDevice
(
virDomainPtr
dom
,
virDomainDeviceDefPtr
dev
)
{
struct
qemud_driver
*
driver
=
(
struct
qemud_driver
*
)
dom
->
conn
->
privateData
;
virDomainObjPtr
vm
=
virDomainFindByUUID
(
&
driver
->
domains
,
dom
->
uuid
);
int
ret
,
i
;
char
*
cmd
,
*
reply
;
char
*
safe_path
;
const
char
*
type
=
virDomainDiskBusTypeToString
(
dev
->
data
.
disk
->
bus
);
if
(
!
vm
)
{
qemudReportError
(
dom
->
conn
,
dom
,
NULL
,
VIR_ERR_INVALID_DOMAIN
,
"%s"
,
_
(
"no domain with matching uuid"
));
return
-
1
;
}
for
(
i
=
0
;
i
<
vm
->
def
->
ndisks
;
i
++
)
{
if
(
STREQ
(
vm
->
def
->
disks
[
i
]
->
dst
,
dev
->
data
.
disk
->
dst
))
{
qemudReportError
(
dom
->
conn
,
dom
,
NULL
,
VIR_ERR_OPERATION_FAILED
,
_
(
"target %s already exists"
),
dev
->
data
.
disk
->
dst
);
return
-
1
;
}
}
if
(
VIR_REALLOC_N
(
vm
->
def
->
disks
,
vm
->
def
->
ndisks
+
1
)
<
0
)
{
qemudReportError
(
dom
->
conn
,
NULL
,
NULL
,
VIR_ERR_NO_MEMORY
,
NULL
);
return
-
1
;
}
safe_path
=
qemudEscapeMonitorArg
(
dev
->
data
.
disk
->
src
);
if
(
!
safe_path
)
{
qemudReportError
(
dom
->
conn
,
dom
,
NULL
,
VIR_ERR_OPERATION_FAILED
,
"%s"
,
_
(
"out of memory"
));
return
-
1
;
}
ret
=
asprintf
(
&
cmd
,
"pci_add 0 storage file=%s,if=%s"
,
safe_path
,
type
);
VIR_FREE
(
safe_path
);
if
(
ret
==
-
1
)
{
qemudReportError
(
dom
->
conn
,
NULL
,
NULL
,
VIR_ERR_NO_MEMORY
,
NULL
);
return
ret
;
}
if
(
qemudMonitorCommand
(
driver
,
vm
,
cmd
,
&
reply
)
<
0
)
{
qemudReportError
(
dom
->
conn
,
dom
,
NULL
,
VIR_ERR_OPERATION_FAILED
,
_
(
"cannot attach %s disk"
),
type
);
VIR_FREE
(
cmd
);
return
-
1
;
}
DEBUG
(
"pci_add reply: %s"
,
reply
);
/* If the command succeeds qemu prints:
* OK bus 0... */
if
(
!
strstr
(
reply
,
"OK bus 0"
))
{
qemudReportError
(
dom
->
conn
,
dom
,
NULL
,
VIR_ERR_OPERATION_FAILED
,
_
(
"adding %s disk failed"
),
type
);
VIR_FREE
(
reply
);
VIR_FREE
(
cmd
);
return
-
1
;
}
vm
->
def
->
disks
[
vm
->
def
->
ndisks
++
]
=
dev
->
data
.
disk
;
qsort
(
vm
->
def
->
disks
,
vm
->
def
->
ndisks
,
sizeof
(
*
vm
->
def
->
disks
),
virDomainDiskQSort
);
VIR_FREE
(
reply
);
VIR_FREE
(
cmd
);
return
0
;
}
static
int
qemudDomainAttachUsbMassstorageDevice
(
virDomainPtr
dom
,
virDomainDeviceDefPtr
dev
)
{
...
...
@@ -2624,7 +2693,7 @@ static int qemudDomainAttachDevice(virDomainPtr dom,
struct
qemud_driver
*
driver
=
(
struct
qemud_driver
*
)
dom
->
conn
->
privateData
;
virDomainObjPtr
vm
=
virDomainFindByUUID
(
&
driver
->
domains
,
dom
->
uuid
);
virDomainDeviceDefPtr
dev
;
int
ret
=
0
;
int
ret
=
0
,
supported
=
0
;
if
(
!
vm
)
{
qemudReportError
(
dom
->
conn
,
dom
,
NULL
,
VIR_ERR_INVALID_DOMAIN
,
...
...
@@ -2643,19 +2712,32 @@ static int qemudDomainAttachDevice(virDomainPtr dom,
return
-
1
;
}
if
(
dev
->
type
==
VIR_DOMAIN_DEVICE_DISK
&&
(
dev
->
data
.
disk
->
device
==
VIR_DOMAIN_DISK_DEVICE_CDROM
||
dev
->
data
.
disk
->
device
==
VIR_DOMAIN_DISK_DEVICE_FLOPPY
))
{
if
(
dev
->
type
==
VIR_DOMAIN_DEVICE_DISK
)
{
switch
(
dev
->
data
.
disk
->
device
)
{
case
VIR_DOMAIN_DISK_DEVICE_CDROM
:
case
VIR_DOMAIN_DISK_DEVICE_FLOPPY
:
supported
=
1
;
ret
=
qemudDomainChangeEjectableMedia
(
dom
,
dev
);
}
else
if
(
dev
->
type
==
VIR_DOMAIN_DEVICE_DISK
&&
dev
->
data
.
disk
->
device
==
VIR_DOMAIN_DISK_DEVICE_DISK
&&
dev
->
data
.
disk
->
bus
==
VIR_DOMAIN_DISK_BUS_USB
)
{
ret
=
qemudDomainAttachUsbMassstorageDevice
(
dom
,
dev
);
break
;
case
VIR_DOMAIN_DISK_DEVICE_DISK
:
if
(
dev
->
data
.
disk
->
bus
==
VIR_DOMAIN_DISK_BUS_USB
)
{
supported
=
1
;
ret
=
qemudDomainAttachUsbMassstorageDevice
(
dom
,
dev
);
}
else
if
(
dev
->
data
.
disk
->
bus
==
VIR_DOMAIN_DISK_BUS_SCSI
||
dev
->
data
.
disk
->
bus
==
VIR_DOMAIN_DISK_BUS_VIRTIO
)
{
supported
=
1
;
ret
=
qemudDomainAttachDiskDevice
(
dom
,
dev
);
}
break
;
}
}
else
if
(
dev
->
type
==
VIR_DOMAIN_DEVICE_HOSTDEV
&&
dev
->
data
.
hostdev
->
mode
==
VIR_DOMAIN_HOSTDEV_MODE_SUBSYS
&&
dev
->
data
.
hostdev
->
source
.
subsys
.
type
==
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB
)
{
supported
=
1
;
ret
=
qemudDomainAttachHostDevice
(
dom
,
dev
);
}
else
{
}
if
(
!
supported
)
{
qemudReportError
(
dom
->
conn
,
dom
,
NULL
,
VIR_ERR_NO_SUPPORT
,
"%s"
,
_
(
"this device type cannot be attached"
));
ret
=
-
1
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录