Re: [libvirt] [PATCH] conf: Remove the actual hostdev when removing a network

2013-09-04 Thread Peter Krempa
On 09/03/13 19:14, Eric Blake wrote:
 On 09/03/2013 09:29 AM, Peter Krempa wrote:
 Commit 50348e6edfa reused the code to remove the hostdev portion of a
 network definition on multiple places but forgot to take into account
 that sometimes the actual network is passed and in some cases the
 parent of that.

 This patch uses the virDomainNetGetActualHostdev() helper to acquire the
 correct pointer all the time while removing the hostdev portion from the
 list.
 ---
  src/conf/domain_conf.c | 14 +++---
  1 file changed, 7 insertions(+), 7 deletions(-)
 
 ACK.
 


Pushed; Thanks.

Peter



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] conf: Remove the actual hostdev when removing a network

2013-09-04 Thread Cole Robinson
On 09/03/2013 11:29 AM, Peter Krempa wrote:
 Commit 50348e6edfa reused the code to remove the hostdev portion of a
 network definition on multiple places but forgot to take into account
 that sometimes the actual network is passed and in some cases the
 parent of that.
 
 This patch uses the virDomainNetGetActualHostdev() helper to acquire the
 correct pointer all the time while removing the hostdev portion from the
 list.
 ---
  src/conf/domain_conf.c | 14 +++---
  1 file changed, 7 insertions(+), 7 deletions(-)
 
 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
 index e412f28..cef4cf9 100644
 --- a/src/conf/domain_conf.c
 +++ b/src/conf/domain_conf.c
 @@ -10002,14 +10002,14 @@ void
  virDomainNetRemoveHostdev(virDomainDefPtr def,
virDomainNetDefPtr net)
  {
 -if (net-type == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
 -/* hostdev net devices are normally also be in the hostdevs
 - * array, but might have already been removed by the time we
 - * get here.
 - */
 -virDomainHostdevDefPtr hostdev = net-data.hostdev.def;
 -size_t i;
 +/* hostdev net devices are normally also be in the hostdevs
 + * array, but might have already been removed by the time we
 + * get here.
 + */
 +virDomainHostdevDefPtr hostdev = virDomainNetGetActualHostdev(net);
 +size_t i;
 
 +if (hostdev) {
  for (i = 0; i  def-nhostdevs; i++) {
  if (def-hostdevs[i] == hostdev) {
  virDomainHostdevRemove(def, i);
 

This causes a crash for me on failed guest startup. XML attached, guest is
legitimately failing because libvirt doesn't know about the CPU model it
specifies. Reverting this patch fixes the crash. Snipped backtrace:

#0  virDomainNetGetActualHostdev (iface=iface@entry=0x7fffd41d7930)
at conf/domain_conf.c:17879
#1  0x77562f10 in virDomainNetRemoveHostdev (
def=def@entry=0x7fffd41c7400, net=net@entry=0x7fffd41d7930)
at conf/domain_conf.c:10009
#2  0x7fffddda5d65 in qemuProcessStop (driver=driver@entry=0x7fffd409f0c0,
vm=vm@entry=0x7fffd41c7ea0, reason=reason@entry=VIR_DOMAIN_SHUTOFF_FAILED,
flags=flags@entry=2) at qemu/qemu_process.c:4270
#3  0x7fffddda7e01 in qemuProcessStart (conn=conn@entry=0x7fffda80,
driver=driver@entry=0x7fffd409f0c0, vm=vm@entry=0x7fffd41c7ea0,
migrateFrom=migrateFrom@entry=0x0, stdin_fd=stdin_fd@entry=-1,
stdin_path=stdin_path@entry=0x0, snapshot=snapshot@entry=0x0,
vmop=vmop@entry=VIR_NETDEV_VPORT_PROFILE_OP_CREATE, flags=optimized out,
flags@entry=1) at qemu/qemu_process.c:4051

- Cole

domain type='qemu'
  namef19-arm-virtio/name
  uuidaaf2c9da-aab2-3244-be96-9a23b85f6b07/uuid
  descriptionf19 arm guest w/ virtio config/description
  memory unit='KiB'1048576/memory
  currentMemory unit='KiB'1048576/currentMemory
  vcpu placement='static'1/vcpu
  os
type arch='armv7l' machine='vexpress-a9'hvm/type
kernel/mnt/data/devel/images/f19-arm.kernel/kernel
initrd/mnt/data/devel/images/f19-arm.initrd/initrd
cmdlineconsole=ttyAMA0 rw root=/dev/vda3/cmdline
dtb/mnt/data/devel/images/f19-arm.dtb/dtb
boot dev='hd'/
  /os
  features
acpi/
apic/
pae/
  /features
  cpu mode='custom' match='exact'
model fallback='allow'cortex-a15/model
  /cpu
  clock offset='utc'/
  on_poweroffdestroy/on_poweroff
  on_rebootrestart/on_reboot
  on_crashrestart/on_crash
  devices
emulator/bin/qemu-system-arm/emulator
disk type='file' device='disk'
  driver name='qemu' type='raw'/
  source file='/mnt/data/devel/images/f19-arm.raw'/
  target dev='vda' bus='virtio'/
  address type='virtio-mmio'/
/disk
interface type='network'
  mac address='52:54:00:92:86:86'/
  source network='default'/
  model type='virtio'/
  address type='virtio-mmio'/
/interface
serial type='pty'
  target port='0'/
/serial
console type='pty'
  target type='serial' port='0'/
/console
  /devices
/domain

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] conf: Remove the actual hostdev when removing a network

2013-09-04 Thread Peter Krempa
On 09/04/13 17:17, Cole Robinson wrote:
 On 09/03/2013 11:29 AM, Peter Krempa wrote:
 Commit 50348e6edfa reused the code to remove the hostdev portion of a
 network definition on multiple places but forgot to take into account
 that sometimes the actual network is passed and in some cases the
 parent of that.

 This patch uses the virDomainNetGetActualHostdev() helper to acquire the
 correct pointer all the time while removing the hostdev portion from the
 list.
 ---
  src/conf/domain_conf.c | 14 +++---
  1 file changed, 7 insertions(+), 7 deletions(-)

 diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
 index e412f28..cef4cf9 100644
 --- a/src/conf/domain_conf.c
 +++ b/src/conf/domain_conf.c
 @@ -10002,14 +10002,14 @@ void
  virDomainNetRemoveHostdev(virDomainDefPtr def,
virDomainNetDefPtr net)
  {
 -if (net-type == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
 -/* hostdev net devices are normally also be in the hostdevs
 - * array, but might have already been removed by the time we
 - * get here.
 - */
 -virDomainHostdevDefPtr hostdev = net-data.hostdev.def;
 -size_t i;
 +/* hostdev net devices are normally also be in the hostdevs
 + * array, but might have already been removed by the time we
 + * get here.
 + */
 +virDomainHostdevDefPtr hostdev = virDomainNetGetActualHostdev(net);
 +size_t i;

 +if (hostdev) {
  for (i = 0; i  def-nhostdevs; i++) {
  if (def-hostdevs[i] == hostdev) {
  virDomainHostdevRemove(def, i);

 
 This causes a crash for me on failed guest startup. XML attached, guest is
 legitimately failing because libvirt doesn't know about the CPU model it
 specifies. Reverting this patch fixes the crash. Snipped backtrace:
 
 #0  virDomainNetGetActualHostdev (iface=iface@entry=0x7fffd41d7930)
 at conf/domain_conf.c:17879
 #1  0x77562f10 in virDomainNetRemoveHostdev (
 def=def@entry=0x7fffd41c7400, net=net@entry=0x7fffd41d7930)
 at conf/domain_conf.c:10009
 #2  0x7fffddda5d65 in qemuProcessStop (driver=driver@entry=0x7fffd409f0c0,
 vm=vm@entry=0x7fffd41c7ea0, reason=reason@entry=VIR_DOMAIN_SHUTOFF_FAILED,
 flags=flags@entry=2) at qemu/qemu_process.c:4270
 #3  0x7fffddda7e01 in qemuProcessStart (conn=conn@entry=0x7fffda80,
 driver=driver@entry=0x7fffd409f0c0, vm=vm@entry=0x7fffd41c7ea0,
 migrateFrom=migrateFrom@entry=0x0, stdin_fd=stdin_fd@entry=-1,
 stdin_path=stdin_path@entry=0x0, snapshot=snapshot@entry=0x0,
 vmop=vmop@entry=VIR_NETDEV_VPORT_PROFILE_OP_CREATE, flags=optimized out,
 flags@entry=1) at qemu/qemu_process.c:4051
 
 - Cole
 

d'oh, virDomainNetGetActualHostdev isn't bulletproof in case the actual
network interface isn't allocated. I'll post a patch asap.

Peter



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

[libvirt] [PATCH] conf: Remove the actual hostdev when removing a network

2013-09-03 Thread Peter Krempa
Commit 50348e6edfa reused the code to remove the hostdev portion of a
network definition on multiple places but forgot to take into account
that sometimes the actual network is passed and in some cases the
parent of that.

This patch uses the virDomainNetGetActualHostdev() helper to acquire the
correct pointer all the time while removing the hostdev portion from the
list.
---
 src/conf/domain_conf.c | 14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index e412f28..cef4cf9 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -10002,14 +10002,14 @@ void
 virDomainNetRemoveHostdev(virDomainDefPtr def,
   virDomainNetDefPtr net)
 {
-if (net-type == VIR_DOMAIN_NET_TYPE_HOSTDEV) {
-/* hostdev net devices are normally also be in the hostdevs
- * array, but might have already been removed by the time we
- * get here.
- */
-virDomainHostdevDefPtr hostdev = net-data.hostdev.def;
-size_t i;
+/* hostdev net devices are normally also be in the hostdevs
+ * array, but might have already been removed by the time we
+ * get here.
+ */
+virDomainHostdevDefPtr hostdev = virDomainNetGetActualHostdev(net);
+size_t i;

+if (hostdev) {
 for (i = 0; i  def-nhostdevs; i++) {
 if (def-hostdevs[i] == hostdev) {
 virDomainHostdevRemove(def, i);
-- 
1.8.3.2

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list


Re: [libvirt] [PATCH] conf: Remove the actual hostdev when removing a network

2013-09-03 Thread Eric Blake
On 09/03/2013 09:29 AM, Peter Krempa wrote:
 Commit 50348e6edfa reused the code to remove the hostdev portion of a
 network definition on multiple places but forgot to take into account
 that sometimes the actual network is passed and in some cases the
 parent of that.
 
 This patch uses the virDomainNetGetActualHostdev() helper to acquire the
 correct pointer all the time while removing the hostdev portion from the
 list.
 ---
  src/conf/domain_conf.c | 14 +++---
  1 file changed, 7 insertions(+), 7 deletions(-)

ACK.

-- 
Eric Blake   eblake redhat com+1-919-301-3266
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list