Finally, everything works for if I simply change my template to <span class="Apple-style-span" style="font-family: verdana, arial, helvetica, sans-serif; font-size: 12px; ">use the /usr/libexec/qemu-kvm instead of /usr/bin/kvm, which is a symbolic link to it.</span><div>
<font class="Apple-style-span" face="verdana, arial, helvetica, sans-serif"><span class="Apple-style-span" style="font-size: 12px;">Not sure why it matters but that does solve all the mysteries.</span></font></div><div><font class="Apple-style-span" face="verdana, arial, helvetica, sans-serif"><span class="Apple-style-span" style="font-size: 12px;"><br>
</span></font></div><div><font class="Apple-style-span" face="verdana, arial, helvetica, sans-serif"><span class="Apple-style-span" style="font-size: 12px;">Shi<br></span></font><br><div class="gmail_quote">On Fri, Mar 4, 2011 at 9:56 AM, Shi Jin <span dir="ltr"><<a href="mailto:jinzishuai@gmail.com">jinzishuai@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div class="gmail_quote"><div class="im"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>It seems that your qemu does not support monitor command 'drive_add'.</div>

What's version of your qemu?<br>
<div><br></div></blockquote></div><div>Thank you. Here is my version</div><div>[cloudadmin@test2 ~]$ /usr/libexec/qemu-kvm -version</div><div>QEMU PC emulator version 0.12.1 (qemu-kvm-0.12.1.2), Copyright (c) 2003-2008 Fabrice Bellard</div>

<div><br></div><div>I finally think it is a permission issue. If I run commands as root and get kvm run by the default qemu user, both attach-disk and detach-disk works like your case.</div><div><br></div><div>However, if I set to run as another user, such as cloudamin, attach-disk works but detach-disk does not.</div>

<div>My libvirtd.conf has</div><div>unix_sock_group = "cloudadmin"</div><div>unix_sock_rw_perms = "0770"</div><div>auth_unix_ro = "none"</div><div>auth_unix_rw = "none"</div><div>log_level = 3</div>

<div>log_outputs="3:file:/var/log/libvirt/libvirtd.log"</div><div><br></div><div>and qemu.conf has</div><div>user = "cloudadmin"</div><div>group = "cloudadmin"</div><div>dynamic_ownership = 0</div>

<div><br></div><div>All images are owned by the cloudadmin:cloudadmin.</div><div><br></div><div>Is there a problem with this setup?<br><br></div><div class="im"><div>Thank you very much.<br>Shi </div></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

<div>
> 15:31:52.902: debug : virEventRunOnce:595 : Poll got 1 event<div><div></div><div class="h5"><br>
> 15:31:52.902: debug : virEventDispatchTimeouts:405 : Dispatch 3<br>
> 15:31:52.902: debug : qemuMonitorAddDevice:1878 : mon=0x7f3628341370<br>
> device=virtio-blk-pci,bus=pci.0,addr=0x6,drive=drive-virtio-disk1,id=virtio-disk1<br>
<br>
</div></div></div><div><div></div><div class="h5">When 'drive_add' failes, we do not call qemuMonitorAddDevice(). But it is called.<br>
<div><br>
> 15:31:52.902: debug : virEventDispatchHandles:450 : Dispatch 8<br>
> 15:31:52.902: debug : qemuMonitorCommandWithHandler:230 : Send command<br>
> 'device_add<br>
> virtio-blk-pci,bus=pci.0,addr=0x6,drive=drive-virtio-disk1,id=virtio-disk1'<br>
> for write with FD -1<br>
<br>
</div>What's the reply of command 'device_add'? Can you provide it. I think it should fail.<br>
<br>
Thanks.<br>
<font color="#888888">Wen Congyang<br>
</font><div><div></div><div><br>
><br>
> Than you very much.<br>
><br>
> Shi<br>
><br>
><br>
><br>
><br>
><br>
> On Thu, Mar 3, 2011 at 10:12 PM, Wen Congyang <<a href="mailto:wency@cn.fujitsu.com" target="_blank">wency@cn.fujitsu.com</a>> wrote:<br>
><br>
>> At 03/04/2011 01:00 PM, Shi Jin Write:<br>
>>>><br>
>>>><br>
>>>><br>
>>>>     <disk type='file' device='disk'><br>
>>>>       <driver name='qemu' type='qcow2' cache='none'/><br>
>>>>      <source file='/var/lib/libvirt/images/rhel6rc_64.img'/><br>
>>>>      <target dev='hda' bus='ide'/><br>
>>>>      <alias name='ide0-0-0'/><br>
>>>>      <address type='drive' controller='0' bus='0' unit='0'/><br>
>>>>    </disk><br>
>>>>    <disk type='file' device='cdrom'><br>
>>>>      <driver name='qemu' type='raw'/><br>
>>>>      <source file='/var/lib/libvirt/images/test.iso'/><br>
>>>>      <target dev='hdc' bus='ide'/><br>
>>>>      <readonly/><br>
>>>>      <alias name='ide0-1-0'/><br>
>>>>      <address type='drive' controller='0' bus='1' unit='0'/><br>
>>>>    </disk><br>
>>>>     <disk type='file' device='disk'><br>
>>>>      <driver name='file' type='qcow2'/><br>
>>>>       <source file='/var/lib/libvirt/images/test3.img'/><br>
>>>>       <target dev='vdb' bus='virtio'/><br>
>>>>       <alias name='virtio-disk1'/><br>
>>>>      <address type='pci' domain='0x0000' bus='0x00' slot='0x06'<br>
>>>> function='0x0'/><br>
>>>>    </disk><br>
>>>>    <controller type='ide' index='0'><br>
>>>>      <alias name='ide0'/><br>
>>>>      <address type='pci' domain='0x0000' bus='0x00' slot='0x01'<br>
>>>> function='0x1'/><br>
>>>>    </controller><br>
>>>><br>
>>>><br>
>>>> Thank you very much. It is exactly the same output as mine, particularly<br>
>>>  <driver name='file' type='qcow2'/><br>
>>> I thought it has to be name='qemu' to detach properly but since you<br>
>> didn't<br>
>>> have a problem, I am very lost on why mine didn't work.<br>
>>><br>
>>> My libvirtd.log shows (with debugging turned on)<br>
>>> 14:43:18.965: debug : qemuMonitorCommandWithHandler:235 : Receive command<br>
>>> reply ret=0 errno=0 33 bytes 'Device 'virtio-disk1' not found^M<br>
>>> '<br>
>>> 14:43:18.965: debug : virEventDispatchTimeouts:405 : Dispatch 3<br>
>>> 14:43:18.965: debug : virEventDispatchHandles:450 : Dispatch 8<br>
>>> 14:43:18.965: error : qemuMonitorTextDelDevice:2314 : operation failed:<br>
>>> detaching virtio-disk1 device failed: Device 'virtio-disk1' not found^M<br>
>>><br>
>>> Do you know what the "device not found" error means?<br>
>><br>
>> It seems attaching virtio-disk1 failed.<br>
>> Can you provide the log when you attach virtio-disk1?<br>
>><br>
>> Thanks.<br>
>> Wen Congyang<br>
>><br>
>>><br>
>>> Thanks.<br>
>>><br>
>>> Shi<br>
>>><br>
>><br>
>><br>
><br>
><br>
<br>
</div></div></div></div></blockquote></div><font color="#888888"><br><br clear="all"><br>-- <br>Shi Jin, Ph.D.<br><br>
</font></blockquote></div><br><br clear="all"><br>-- <br>Shi Jin, Ph.D.<br><br>
</div>