Re: [kvm-devel] [PATCH] kvm: provide kvm.h for all architecture: fixes headers_install

2008-03-11 Thread Christian Borntraeger
Am Dienstag, 11. März 2008 schrieb David Woodhouse:
> 
> On Mon, 2008-03-10 at 23:20 -0700, Andrew Morton wrote:
> > 
> > > Changes since v1:
> > > o use asm-generic/Kbuild.asm (Arnd Bergmann)
> 
> I don't see that in the diffstat of the patch you dropped (looking at
> the immediately subsequent mail in my inbox). Which might explain...


I cross tested my patch on all architectures and, yes, that part did not make
it into mm. Maybe it was caused by my last patch being word wrapped.
Here is a resend:


[PATCH v2] kvm: provide kvm.h for all architecture: fixes headers_install

Currently include/linux/kvm.h is not considered by make headers_install, 
because Kbuild cannot handle " unifdef-$(CONFIG_FOO) += foo.h. 
This problem was introduced by 040922c04cf2c8ac70be2e88a8a9614ecdb41d2e, 
which makes this an 2.6.25 regression.

One way of solving the issue is to enhance Kbuild, but Avi and David 
conviced me, that changing headers_install is not the way to go. This patch 
changes the definition for linux/kvm.h to unifdef-y.

If  unifdef-y is used for linux/kvm.h "make headers_check" will fail on all
architectures without asm/kvm.h. Therefore, this patch also provides 
asm/kvm.h on all architectures.

Changes since v1:
o use asm-generic/Kbuild.asm (Arnd Bergmann)
o fix comment in asm-frv (David Howells)

Signed-off-by: Christian Borntraeger <[EMAIL PROTECTED]>
Acked-by: Avi Kivity <[EMAIL PROTECTED]>
CCed: Sam Ravnborg <[EMAIL PROTECTED]
CCed: David Woodhouse <[EMAIL PROTECTED]>

---
 include/asm-alpha/kvm.h|6 ++
 include/asm-arm/kvm.h  |6 ++
 include/asm-avr32/kvm.h|6 ++
 include/asm-blackfin/kvm.h |6 ++
 include/asm-cris/kvm.h |6 ++
 include/asm-frv/kvm.h  |6 ++
 include/asm-generic/Kbuild.asm |2 ++
 include/asm-h8300/kvm.h|6 ++
 include/asm-ia64/kvm.h |6 ++
 include/asm-m32r/kvm.h |6 ++
 include/asm-m68k/kvm.h |6 ++
 include/asm-m68knommu/kvm.h|6 ++
 include/asm-mips/kvm.h |6 ++
 include/asm-mn10300/kvm.h  |6 ++
 include/asm-parisc/kvm.h   |6 ++
 include/asm-powerpc/kvm.h  |6 ++
 include/asm-s390/kvm.h |6 ++
 include/asm-sh/kvm.h   |6 ++
 include/asm-sparc/kvm.h|6 ++
 include/asm-sparc64/kvm.h  |6 ++
 include/asm-um/kvm.h   |6 ++
 include/asm-v850/kvm.h |6 ++
 include/asm-xtensa/kvm.h   |6 ++
 include/linux/Kbuild   |2 +-
 24 files changed, 135 insertions(+), 1 deletion(-)

Index: linux-2.6.git/include/asm-alpha/kvm.h
===
--- /dev/null
+++ linux-2.6.git/include/asm-alpha/kvm.h
@@ -0,0 +1,6 @@
+#ifndef __LINUX_KVM_ALPHA_H
+#define __LINUX_KVM_ALPHA_H
+
+/* alpha does not support KVM */
+
+#endif
Index: linux-2.6.git/include/asm-arm/kvm.h
===
--- /dev/null
+++ linux-2.6.git/include/asm-arm/kvm.h
@@ -0,0 +1,6 @@
+#ifndef __LINUX_KVM_ARM_H
+#define __LINUX_KVM_ARM_H
+
+/* arm does not support KVM */
+
+#endif
Index: linux-2.6.git/include/asm-avr32/kvm.h
===
--- /dev/null
+++ linux-2.6.git/include/asm-avr32/kvm.h
@@ -0,0 +1,6 @@
+#ifndef __LINUX_KVM_AVR32_H
+#define __LINUX_KVM_AVR32_H
+
+/* avr32 does not support KVM */
+
+#endif
Index: linux-2.6.git/include/asm-blackfin/kvm.h
===
--- /dev/null
+++ linux-2.6.git/include/asm-blackfin/kvm.h
@@ -0,0 +1,6 @@
+#ifndef __LINUX_KVM_BLACKFIN_H
+#define __LINUX_KVM_BLACKFIN_H
+
+/* blackfin does not support KVM */
+
+#endif
Index: linux-2.6.git/include/asm-cris/kvm.h
===
--- /dev/null
+++ linux-2.6.git/include/asm-cris/kvm.h
@@ -0,0 +1,6 @@
+#ifndef __LINUX_KVM_CRIS_H
+#define __LINUX_KVM_CRIS_H
+
+/* cris does not support KVM */
+
+#endif
Index: linux-2.6.git/include/asm-frv/kvm.h
===
--- /dev/null
+++ linux-2.6.git/include/asm-frv/kvm.h
@@ -0,0 +1,6 @@
+#ifndef __LINUX_KVM_FRV_H
+#define __LINUX_KVM_FRV_H
+
+/* frv does not support KVM */
+
+#endif
Index: linux-2.6.git/include/asm-generic/Kbuild.asm
===
--- linux-2.6.git.orig/include/asm-generic/Kbuild.asm
+++ linux-2.6.git/include/asm-generic/Kbuild.asm
@@ -1,3 +1,5 @@
+header-y  += kvm.h
+
 ifeq ($(wildcard 
include/asm-$(SRCARCH)/a.out.h),include/asm-$(SRCARCH)/a.out.h)
 unifdef-y += a.out.h
 endif
Index: linux-2.6.git/include/asm-h8300/kvm.h
===
--- /dev/null
+++ linux-2.6.git/include/asm-h8300/kvm.h
@@ -0,0 +1,6 @@
+#ifndef __LINUX_KVM_H8300_H
+#define __LINUX_KVM_H8300_H
+
+/* h

[kvm-devel] D e ntists Contact List in the US

2008-03-11 Thread Everett Luna





New for 2008 Dentis.try Contact List in the United States

--> 164,204 D entists with City, State, Zip
--> 158,918 Mailing Addresses
--> 163,665 Tel #'s
--> 77,397 Facsimile Numbers
--> 45,265 Email Addys

Only until March 14 the special introductory price is $299 (reduced from $396)

To inquire please write to [EMAIL PROTECTED]








for termination of this mail send a blank message with 6425 in the subject

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH] kvm: provide kvm.h for all architecture: fixes headers_install

2008-03-11 Thread Andreas Schwab
Christian Borntraeger <[EMAIL PROTECTED]> writes:

>  include/asm-alpha/kvm.h|6 ++

Can't you put it in asm-generic?

Andreas.

-- 
Andreas Schwab, SuSE Labs, [EMAIL PROTECTED]
SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany
PGP key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] Запасы

2008-03-11 Thread Отдел логистики
  Приглашаем Вас принять участие в курсе :

   -
  |Управление запасами в|
  |современной компании |
  | |
  | 24 - 26 марта 2008 г.   |
  |Санкт-Петербург  |
  | |
   -

  В рамках программы мероприятия:
  ---

> Формирование логистической системы
  Функции отдела логистики
  Основные блоки логистики
  Основной результат работы логистики - оптимизация расходов

> Оптимальный выбор партнеров по бизнесу - минимум расходов
  Технология выбора и оценки поставщика
  Процесс выбора поставщика
  Методика оценки работы поставщика
  Контроль складских запасов по показателям оборачиваемости

> Проблематика управления запасами
  Возможности снижения уровня запасов
  Пересечение интересов службы по управлению запасами и 
  других функциональных подразделений компании

> Анализ и дифференциация ассортимента
  Неликвиды. Последствия дефицита. Взаимозаменяемые товары
  АВС-анализ в управлении запасами
  Использование метода XYZ

> Прогнозирование потребности в управлении запасами
  Статистические методы прогнозирования
  Учет сезонных колебаний
  Экспертная оценка

> Отчетность при управлении запасами
  Калькуляция затрат, связанных с управлением запасами
  Пути снижения затрат
  Разработка отчетов и периодичность их составления

> Параметры поставок
  Логистический цикл запасов
  Определение оптимального размера заказа
  Потребность в страховых запасах

> Системы управления запасами
  Планирование управления запасами
  Модели управления запасами
  Управление многономенклатурными запасами

> Логистический прогноз: основы, методы, единицы измерения

> Методы логистического планирования

 За дополнительной информацие обращайтесь по телефону
-= (812) 98 3 2906 =-





-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH] kvm: provide kvm.h for all architecture: fixes headers_install

2008-03-11 Thread Christian Borntraeger
Am Dienstag, 11. März 2008 schrieb Andreas Schwab:
> Christian Borntraeger <[EMAIL PROTECTED]> writes:
> 
> >  include/asm-alpha/kvm.h|6 ++
> 
> Can't you put it in asm-generic?

I dont think so. The generic part is in include/linux/kvm.h. asm/kvm.h is 
populated by each architecture which gets kvm support with arch specfic 
definitions. x86 has support and s390, powerpc and ia64 are currently know 
to work on ports. 


Christian

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH] virtio-balloon: do not attempt to release more than available pages

2008-03-11 Thread Rusty Russell
On Tuesday 11 March 2008 11:52:46 Anthony Liguori wrote:
> Rusty Russell wrote:
> > 2) Handle the case where we get nonsense from the host, which causes us
> > to wrap around.
>
> Here's my neither compiled nor tested version which should fix this
> problem without breaking the ABI.

Hmm, we could just refuse to grab >= 2G pages.  It is not only reasonable, but
also gives us an opportunity to make another Sophie Blanchard reference![1]

Patch below.

Cheers,
Rusty.
[1] Wow, I actually learned something from a Wikipedia Featured Article.

virtio: handle > 2 billion page balloon targets

If the host asks for a huge target towards_target() can overflow, and
we up oops as we try to release more pages than we have.  The simple
fix is to use a 64-bit value.

Signed-off-by: Rusty Russell <[EMAIL PROTECTED]>

diff -r fd0c80dbbd95 drivers/virtio/virtio_balloon.c
--- a/drivers/virtio/virtio_balloon.c   Tue Mar 11 09:21:00 2008 +1100
+++ b/drivers/virtio/virtio_balloon.c   Tue Mar 11 11:25:52 2008 +1100
@@ -152,7 +152,7 @@ static void virtballoon_changed(struct v
wake_up(&vb->config_change);
 }
 
-static inline int towards_target(struct virtio_balloon *vb)
+static inline s64 towards_target(struct virtio_balloon *vb)
 {
u32 v;
__virtio_config_val(vb->vdev,
@@ -176,7 +183,7 @@ static int balloon(void *_vballoon)
 
set_freezable();
while (!kthread_should_stop()) {
-   int diff;
+   s64 diff;
 
try_to_freeze();
wait_event_interruptible(vb->config_change,

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] how increase performance of network io in kvm

2008-03-11 Thread Javier Guerra
On Mon, Mar 10, 2008 at 5:37 PM, Dor Laor <[EMAIL PROTECTED]> wrote:
>  We published virtio network drivers for Linux but not yet for Windows.
>  Our virtio drivers for windows are almost done (for rev#1), we'll surely
>  release the binaries for them.

great!!  no need to fool around with xen/vmware then :-)

any word about availability/license/price on the windows drivers?

>  In the mean time you can use e1000 nic device & driver. It has the best
>  results among the emulated devices and even close to virtio performance.

and for storage? i'm guessing one of the SCSI emulations would be the best...


-- 
Javier

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] KVM developer forum 2008

2008-03-11 Thread Rami Tamir
We'd like to invite all of you to attend the second annual KVM Forum.
Following the success of the last year's event, we'd like to keep the
format similar. The purpose of the forum is to bring together
developers, testers and other technical individuals from within the
community to discuss the state of KVM today. We will also review and
shape the future roadmap of KVM, examine development challenges, and
agree on modes of collaboration needed for common development.

The KVM Forum 2008 will also give developers an opportunity to update
the community on the work that they are doing and coordinate efforts for
the betterment of KVM and Linux virtualization.

Please reserve these dates, the event will take on June 11th - 13th, at
Marriot Napa Valley, California, USA. For those of you who want to get
there earlier, we will be holding a reception cocktail on June 10th
evening time. The registration web site will be up shortly as will the
call for papers

For suggestions and comments please e-mail [EMAIL PROTECTED]



-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] KVM Test result, kernel a16664b.., userspace 3017d05.. one new issue

2008-03-11 Thread Chris Wedgwood
On Mon, Mar 10, 2008 at 05:27:32PM +0800, Yunfeng Zhao wrote:

> One new issue:
> 1.  booting smp windows guests has 30% chance of hang
> https://sourceforge.net/tracker/?func=detail&atid=893831&aid=1910923&group_id=180599

> PlatformWoodcrest
> CPU 4
> Memory size 8G'

Is that a CPU with FlexPriority?

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH 3/6] kvm: qemu: Add option for enable/disable in kernel PIT

2008-03-11 Thread Hollis Blanchard
On Fri, 2008-03-07 at 20:52 +0800, Yang, Sheng wrote:
> From 98543bb3c3821e5bc9003bb91d7d0c755394ffac Mon Sep 17 00:00:00 2001
> From: Sheng Yang <[EMAIL PROTECTED]>
> Date: Fri, 7 Mar 2008 14:24:32 +0800
> Subject: [PATCH] kvm: qemu: Add option for enable/disable in kernel PIT

This patch breaks all non-x86 architectures, since common code now calls
functions defined only in libkvm-x86.c .

-- 
Hollis Blanchard
IBM Linux Technology Center



-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] PCI IO regions must be power of two

2008-03-11 Thread Marcelo Tosatti
Anthony,

Both virtio-net and virtio-block currently register PCI IO space regions
that are not power of two in size.

The decoding process to discover the size of a PCI resource expects it
to be a power of two. The PCI controller masks the size out of what is
written into

config_space + 0x10 + (4 * region_num)

The result is that the size is calculated and registered erroneously 
by the OS:

[EMAIL PROTECTED] ~]# cat /proc/ioports  | grep virtio
  c200-c203 : virtio-pci

This is a virtio-block device whose BAR0 has length (16+20)-1, not 4. 

  BAR0: I/O at 0xc200 [0xc223].

I suggest forcing the size to be power of two as follows:


Index: kvm-userspace.hotplug2/qemu/hw/pci.c
===
--- kvm-userspace.hotplug2.orig/qemu/hw/pci.c
+++ kvm-userspace.hotplug2/qemu/hw/pci.c
@@ -236,6 +236,13 @@ void pci_register_io_region(PCIDevice *p

 if ((unsigned int)region_num >= PCI_NUM_REGIONS)
 return;
+
+/* IO region size must be power of two */
+if (type == PCI_ADDRESS_SPACE_IO && (size & (size-1))) {
+size = size << 1;
+size &= size-1;
+}
+
 r = &pci_dev->io_regions[region_num];
 r->addr = -1;
 r->size = size;


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [patch 14/23] QEMU/KVM: device hot-add

2008-03-11 Thread Marcelo Tosatti
On Wed, Mar 05, 2008 at 07:50:14AM +0200, Avi Kivity wrote:
> Marcelo Tosatti wrote:
> >Add monitor command to hot-add PCI devices (nic and drive).
> >
> >  
> 
> A drive is not a pci device.  One would hot-plug a scsi controller, and 
> then hot-plug a device to that controller.

Changed the syntax from "pci_add drive" to "pci_add storage".

However I'm keeping the possibility of adding a drive to a storage
controller before it is hotplugged for two reasons:

- SCSI drive hotplug is not automatic (at least with the sym53c8xx
controller that is emulated). Its necessary to manually add the drive
in the guest OS.

- Each virtio-block device is currently tied to a single valid
file/device.

A new "drive_add" command has been added to hot-add drives to SCSI
controllers.


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [patch 00/24] QEMU ACPI PCI hotplug support

2008-03-11 Thread Marcelo Tosatti
The following patchset allows PCI hot add/remove through ACPI (handled
by the acpiphp driver on Linux guests).

Comments are welcome.

-- 


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [patch 01/24] QEMU/KVM: add devices to represent PCI slots with _EJ0 method

2008-03-11 Thread Marcelo Tosatti
Presence of _EJ0 method indicates that slots are hot-pluggable.

Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>

Index: kvm-userspace.hotplug2/bios/acpi-dsdt.dsl
===
--- kvm-userspace.hotplug2.orig/bios/acpi-dsdt.dsl
+++ kvm-userspace.hotplug2/bios/acpi-dsdt.dsl
@@ -407,6 +407,161 @@ DefinitionBlock (
 Package() {0x001f, 3, LNKB, 0},
 })
 
+Device (S1) {  // Slot 1
+   Name (_ADR, 0x0001)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S2) {  // Slot 2
+   Name (_ADR, 0x0002)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S3) {  // Slot 3
+   Name (_ADR, 0x0003)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S4) {  // Slot 4
+   Name (_ADR, 0x0004)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S5) {  // Slot 5
+   Name (_ADR, 0x0005)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S6) {  // Slot 6
+   Name (_ADR, 0x0006)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S7) {  // Slot 7
+   Name (_ADR, 0x0007)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S8) {  // Slot 8
+   Name (_ADR, 0x0008)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S9) {  // Slot 9
+   Name (_ADR, 0x0009)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S10) {  // Slot 10
+   Name (_ADR, 0x000A)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S11) {  // Slot 11
+   Name (_ADR, 0x000B)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S12) {  // Slot 12
+   Name (_ADR, 0x000C)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S13) {  // Slot 13
+   Name (_ADR, 0x000D)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S14) {  // Slot 14
+   Name (_ADR, 0x000E)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S15) {  // Slot 15
+   Name (_ADR, 0x000F)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S16) {  // Slot 16
+   Name (_ADR, 0x0010)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S17) {  // Slot 17
+   Name (_ADR, 0x0011)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S18) {  // Slot 18
+   Name (_ADR, 0x0012)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S19) {  // Slot 19
+   Name (_ADR, 0x0013)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S20) {  // Slot 20
+   Name (_ADR, 0x0014)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S21) {  // Slot 21
+   Name (_ADR, 0x0015)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S22) {  // Slot 22
+   Name (_ADR, 0x0016)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S23) {  // Slot 23
+   Name (_ADR, 0x0017)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S24) {  // Slot 24
+   Name (_ADR, 0x0018)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S25) {  // Slot 25
+   Name (_ADR, 0x0019)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S26) {  // Slot 26
+   Name (_ADR, 0x001A)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S27) {  // Slot 27
+   Name (_ADR, 0x001B)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S28) {  // Slot 28
+   Name (_ADR, 0x001C)
+   Method (_EJ0,1) { Return (0x0) }
+}
+
+Device (S29) {  // Slot 29
+   Name (_ADR, 0x001D)
+   Method (_EJ0,1) { Return (0x0) }
+ 

[kvm-devel] [patch 02/24] QEMU/KVM: add OperationRegion and GPE handler for add/removal notification

2008-03-11 Thread Marcelo Tosatti
Use GPE _L01 to notify OSPM.

Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>

Index: kvm-userspace.hotplug2/bios/acpi-dsdt.dsl
===
--- kvm-userspace.hotplug2.orig/bios/acpi-dsdt.dsl
+++ kvm-userspace.hotplug2/bios/acpi-dsdt.dsl
@@ -407,6 +407,13 @@ DefinitionBlock (
 Package() {0x001f, 3, LNKB, 0},
 })
 
+OperationRegion(PCST, SystemIO, 0xae00, 0x08)
+Field (PCST, DWordAcc, NoLock, WriteAsZeros)
+   {
+   PCIU, 32,
+   PCID, 32,
+   }
+
 Device (S1) {  // Slot 1
Name (_ADR, 0x0001)
Method (_EJ0,1) { Return (0x0) }
@@ -1142,6 +1149,256 @@ DefinitionBlock (
 Return(0x01)
 }
 Method(_L01) {
+/* Up status */
+If (And(\_SB.PCI0.PCIU, 0x2)) {
+Notify(\_SB.PCI0.S1, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x4)) {
+Notify(\_SB.PCI0.S2, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x8)) {
+Notify(\_SB.PCI0.S3, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x10)) {
+Notify(\_SB.PCI0.S4, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x20)) {
+Notify(\_SB.PCI0.S5, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x40)) {
+Notify(\_SB.PCI0.S6, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x80)) {
+Notify(\_SB.PCI0.S7, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x0100)) {
+Notify(\_SB.PCI0.S8, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x0200)) {
+Notify(\_SB.PCI0.S9, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x0400)) {
+Notify(\_SB.PCI0.S10, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x0800)) {
+Notify(\_SB.PCI0.S11, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x1000)) {
+Notify(\_SB.PCI0.S12, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x2000)) {
+Notify(\_SB.PCI0.S13, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x4000)) {
+Notify(\_SB.PCI0.S14, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x8000)) {
+Notify(\_SB.PCI0.S15, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x1)) {
+Notify(\_SB.PCI0.S16, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x2)) {
+Notify(\_SB.PCI0.S17, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x4)) {
+Notify(\_SB.PCI0.S18, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x8)) {
+Notify(\_SB.PCI0.S19, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x10)) {
+Notify(\_SB.PCI0.S20, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x20)) {
+Notify(\_SB.PCI0.S21, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x40)) {
+Notify(\_SB.PCI0.S22, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x80)) {
+Notify(\_SB.PCI0.S23, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x100)) {
+Notify(\_SB.PCI0.S24, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x200)) {
+Notify(\_SB.PCI0.S25, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x400)) {
+Notify(\_SB.PCI0.S26, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x800)) {
+Notify(\_SB.PCI0.S27, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x1000)) {
+Notify(\_SB.PCI0.S28, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x2000)) {
+Notify(\_SB.PCI0.S29, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x4000)) {
+Notify(\_SB.PCI0.S30, 0x1)
+}
+
+If (And(\_SB.PCI0.PCIU, 0x8000)) {
+Notify(\_SB.PCI0.S31, 0x1)
+}
+
+/* Down status */
+If (And(\_SB.PCI0.PCID, 0x2)) {
+Notify(\_SB.PCI0.S1, 0x3)
+}
+
+If (And(\_SB.PCI0.PCID, 0x4)) {
+Notify(\_SB.PCI0.S2, 0x3)
+}
+
+If (And(\_SB.PCI0.PCID, 0x8)) {
+Notify(\_SB.PCI0.S3, 0x3)
+}
+
+If (And(\_SB.PCI0.PCID, 0x10)) {
+Notify(\_SB.PCI0.S4, 0x3)
+}
+
+If (And(\_SB.PCI0.PCID, 0x20)) {
+Notify(\_SB.PCI0.S5, 0x3)
+}
+
+If (And(\_SB.PCI0.PCID, 0x40)) {
+Notify(\_SB.PCI0.S6, 0x3)
+}
+
+If (And(\_SB.PCI0.PCID, 0x80)) {
+Not

[kvm-devel] [patch 03/24] QEMU/KVM: add pci_find_bus

2008-03-11 Thread Marcelo Tosatti
Return PCIBus pointer from bus number integer.

Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>

Index: kvm-userspace.hotplug2/qemu/hw/pci.c
===
--- kvm-userspace.hotplug2.orig/qemu/hw/pci.c
+++ kvm-userspace.hotplug2/qemu/hw/pci.c
@@ -675,6 +675,16 @@ static void pci_bridge_write_config(PCID
 pci_default_write_config(d, address, val, len);
 }
 
+PCIBus *pci_find_bus(int bus_num)
+{
+PCIBus *bus = first_bus;
+
+while (bus && bus->bus_num != bus_num)
+bus = bus->next;
+
+return bus;
+}
+
 PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint32_t id,
 pci_map_irq_fn map_irq, const char *name)
 {
Index: kvm-userspace.hotplug2/qemu/hw/pci.h
===
--- kvm-userspace.hotplug2.orig/qemu/hw/pci.h
+++ kvm-userspace.hotplug2/qemu/hw/pci.h
@@ -3,6 +3,7 @@
 
 /* PCI includes legacy ISA access.  */
 #include "isa.h"
+#include 
 
 /* PCI bus */
 
@@ -91,6 +92,7 @@ void pci_data_write(void *opaque, uint32
 uint32_t pci_data_read(void *opaque, uint32_t addr, int len);
 int pci_bus_num(PCIBus *s);
 void pci_for_each_device(int bus_num, void (*fn)(PCIDevice *d));
+PCIBus *pci_find_bus(int bus_num);
 
 void pci_info(void);
 PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint32_t id,

-- 


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [patch 05/24] QEMU/KVM: pci hotplug GPE support

2008-03-11 Thread Marcelo Tosatti
Enable the corresponding bit on the PCIST region and trigger the SCI.

Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>

Index: kvm-userspace.hotplug2/qemu/hw/acpi.c
===
--- kvm-userspace.hotplug2.orig/qemu/hw/acpi.c
+++ kvm-userspace.hotplug2/qemu/hw/acpi.c
@@ -538,6 +538,7 @@ void qemu_system_powerdown(void)
 #endif
 #define GPE_BASE 0xafe0
 #define PROC_BASE 0xaf00
+#define PCI_BASE 0xae00
 
 struct gpe_regs {
 uint16_t sts; /* status */
@@ -546,7 +547,13 @@ struct gpe_regs {
 uint8_t down;
 };
 
+struct pci_status {
+uint32_t up;
+uint32_t down;
+};
+
 static struct gpe_regs gpe;
+static struct pci_status pci0_status;
 
 static uint32_t gpe_readb(void *opaque, uint32_t addr)
 {
@@ -614,6 +621,45 @@ static void gpe_writeb(void *opaque, uin
 #endif
 }
 
+static uint32_t pcihotplug_read(void *opaque, uint32_t addr)
+{
+uint32_t val = 0;
+struct pci_status *g = opaque;
+switch (addr) {
+case PCI_BASE:
+val = g->up;
+break;
+case PCI_BASE + 4:
+val = g->down;
+break;
+default:
+break;
+}
+
+#if defined(DEBUG)
+printf("pcihotplug read %lx == %lx\n", addr, val);
+#endif
+return val;
+}
+
+static void pcihotplug_write(void *opaque, uint32_t addr, uint32_t val)
+{
+struct pci_status *g = opaque;
+switch (addr) {
+case PCI_BASE:
+g->up = val;
+break;
+case PCI_BASE + 4:
+g->down = val;
+break;
+   }
+
+#if defined(DEBUG)
+printf("pcihotplug write %lx <== %d\n", addr, val);
+#endif
+}
+
+
 static char *model;
 
 void qemu_system_hot_add_init(char *cpu_model)
@@ -624,6 +670,9 @@ void qemu_system_hot_add_init(char *cpu_
 register_ioport_write(PROC_BASE, 4, 1, gpe_writeb, &gpe);
 register_ioport_read(PROC_BASE, 4, 1,  gpe_readb, &gpe);
 
+register_ioport_write(PCI_BASE, 8, 4, pcihotplug_write, &pci0_status);
+register_ioport_read(PCI_BASE, 8, 4,  pcihotplug_read, &pci0_status);
+
 model = cpu_model;
 }
 
@@ -665,3 +714,29 @@ void qemu_system_cpu_hot_add(int cpu, in
 disable_processor(&gpe, cpu);
 qemu_set_irq(pm_state->irq, 0);
 }
+
+static void enable_device(struct pci_status *p, struct gpe_regs *g, int slot)
+{
+g->sts |= 2;
+g->en |= 2;
+p->up |= (1 << slot);
+}
+
+static void disable_device(struct pci_status *p, struct gpe_regs *g, int slot)
+{
+g->sts |= 2;
+g->en |= 2;
+p->down |= (1 << slot);
+}
+
+void qemu_system_device_hot_add(int slot, int state)
+{
+qemu_set_irq(pm_state->irq, 1);
+pci0_status.up = 0;
+pci0_status.down = 0;
+if (state)
+enable_device(&pci0_status, &gpe, slot);
+else
+disable_device(&pci0_status, &gpe, slot);
+qemu_set_irq(pm_state->irq, 0);
+}

-- 


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [patch 06/24] QEMU/KVM: dynamic drive/drive_opt index allocation

2008-03-11 Thread Marcelo Tosatti
Dynamically allocate drive options and drive table index, so to 
reused indexes when devices are removed.

Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>

Index: kvm-userspace.hotplug2/qemu/sysemu.h
===
--- kvm-userspace.hotplug2.orig/qemu/sysemu.h
+++ kvm-userspace.hotplug2/qemu/sysemu.h
@@ -139,6 +139,7 @@ typedef struct DriveInfo {
 BlockInterfaceType type;
 int bus;
 int unit;
+int used;
 } DriveInfo;
 
 #define MAX_IDE_DEVS   2
Index: kvm-userspace.hotplug2/qemu/vl.c
===
--- kvm-userspace.hotplug2.orig/qemu/vl.c
+++ kvm-userspace.hotplug2/qemu/vl.c
@@ -254,6 +254,7 @@ int nb_drives_opt;
 struct drive_opt {
 const char *file;
 char opt[1024];
+int used;
 } drives_opt[MAX_DRIVES];
 
 static CPUState *cur_cpu;
@@ -4952,22 +4953,50 @@ void do_info_network(void)
 #define MTD_ALIAS "if=mtd"
 #define SD_ALIAS "index=0,if=sd"
 
+static int drive_opt_get_free_idx(void)
+{
+int index;
+
+for (index = 0; index < MAX_DRIVES; index++)
+if (!drives_opt[index].used) {
+drives_opt[index].used = 1;
+return index;
+}
+
+return -1;
+}
+
+static int drive_get_free_idx(void)
+{
+int index;
+
+for (index = 0; index < MAX_DRIVES; index++)
+if (!drives_table[index].used) {
+drives_table[index].used = 1;
+return index;
+}
+
+return -1;
+}
+
 static int drive_add(const char *file, const char *fmt, ...)
 {
 va_list ap;
+int index = drive_opt_get_free_idx();
 
-if (nb_drives_opt >= MAX_DRIVES) {
+if (nb_drives_opt >= MAX_DRIVES || index == -1) {
 fprintf(stderr, "qemu: too many drives\n");
 exit(1);
 }
 
-drives_opt[nb_drives_opt].file = file;
+drives_opt[index].file = file;
 va_start(ap, fmt);
-vsnprintf(drives_opt[nb_drives_opt].opt,
+vsnprintf(drives_opt[index].opt,
   sizeof(drives_opt[0].opt), fmt, ap);
 va_end(ap);
 
-return nb_drives_opt++;
+nb_drives_opt++;
+return index;
 }
 
 int drive_get_index(BlockInterfaceType type, int bus, int unit)
@@ -4976,10 +5005,11 @@ int drive_get_index(BlockInterfaceType t
 
 /* seek interface, bus and unit */
 
-for (index = 0; index < nb_drives; index++)
+for (index = 0; index < MAX_DRIVES; index++)
 if (drives_table[index].type == type &&
drives_table[index].bus == bus &&
-   drives_table[index].unit == unit)
+   drives_table[index].unit == unit &&
+   drives_table[index].used)
 return index;
 
 return -1;
@@ -5015,6 +5045,7 @@ static int drive_init(struct drive_opt *
 int index;
 int cache;
 int bdrv_flags;
+int drives_table_idx;
 char *str = arg->opt;
 char *params[] = { "bus", "unit", "if", "index", "cyls", "heads",
"secs", "trans", "media", "snapshot", "file",
@@ -5266,10 +5297,11 @@ static int drive_init(struct drive_opt *
 snprintf(buf, sizeof(buf), "%s%s%i",
  devname, mediastr, unit_id);
 bdrv = bdrv_new(buf);
-drives_table[nb_drives].bdrv = bdrv;
-drives_table[nb_drives].type = type;
-drives_table[nb_drives].bus = bus_id;
-drives_table[nb_drives].unit = unit_id;
+drives_table_idx = drive_get_free_idx();
+drives_table[drives_table_idx].bdrv = bdrv;
+drives_table[drives_table_idx].type = type;
+drives_table[drives_table_idx].bus = bus_id;
+drives_table[drives_table_idx].unit = unit_id;
 nb_drives++;
 
 switch(type) {
@@ -9578,8 +9610,10 @@ int main(int argc, char **argv)
 if (nb_drives_opt < MAX_DRIVES)
 drive_add(NULL, SD_ALIAS);
 
-/* open the virtual block devices */
-
+/* open the virtual block devices
+ * note that migration with device
+ * hot add/remove is broken.
+ */
 for(i = 0; i < nb_drives_opt; i++)
 if (drive_init(&drives_opt[i], snapshot, machine) == -1)
exit(1);

-- 


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [patch 04/24] QEMU/KVM: return PCIDevice on net device init and record devfn

2008-03-11 Thread Marcelo Tosatti
Change the PCI network drivers init functions to return the PCIDev, to
inform which slot has been hot-plugged.

Also record devfn on the NICInfo structure to locate for release
on hot-removal.

Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>

Index: kvm-userspace.hotplug2/qemu/hw/e1000.c
===
--- kvm-userspace.hotplug2.orig/qemu/hw/e1000.c
+++ kvm-userspace.hotplug2/qemu/hw/e1000.c
@@ -930,7 +930,7 @@ e1000_mmio_map(PCIDevice *pci_dev, int r
 cpu_register_physical_memory(addr, PNPMMIO_SIZE, d->mmio_index);
 }
 
-void
+PCIDevice *
 pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn)
 {
 E1000State *d;
@@ -994,4 +994,6 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd,
  d->nd->macaddr[3], d->nd->macaddr[4], d->nd->macaddr[5]);
 
 register_savevm(info_str, d->instance, 1, nic_save, nic_load, d);
+
+return (PCIDevice *)d;
 }
Index: kvm-userspace.hotplug2/qemu/hw/eepro100.c
===
--- kvm-userspace.hotplug2.orig/qemu/hw/eepro100.c
+++ kvm-userspace.hotplug2/qemu/hw/eepro100.c
@@ -1742,7 +1742,7 @@ static void nic_save(QEMUFile * f, void 
 qemu_put_buffer(f, s->configuration, sizeof(s->configuration));
 }
 
-static void nic_init(PCIBus * bus, NICInfo * nd,
+static PCIDevice *nic_init(PCIBus * bus, NICInfo * nd,
  const char *name, uint32_t device)
 {
 PCIEEPRO100State *d;
@@ -1794,22 +1794,23 @@ static void nic_init(PCIBus * bus, NICIn
 
 /* XXX: instance number ? */
 register_savevm(name, 0, 3, nic_save, nic_load, s);
+return (PCIDevice *)d;
 }
 
-void pci_i82551_init(PCIBus * bus, NICInfo * nd, int devfn)
+PCIDevice *pci_i82551_init(PCIBus * bus, NICInfo * nd, int devfn)
 {
-nic_init(bus, nd, "i82551", i82551);
+return nic_init(bus, nd, "i82551", i82551);
 //~ uint8_t *pci_conf = d->dev.config;
 }
 
-void pci_i82557b_init(PCIBus * bus, NICInfo * nd, int devfn)
+PCIDevice *pci_i82557b_init(PCIBus * bus, NICInfo * nd, int devfn)
 {
-nic_init(bus, nd, "i82557b", i82557B);
+return nic_init(bus, nd, "i82557b", i82557B);
 }
 
-void pci_i82559er_init(PCIBus * bus, NICInfo * nd, int devfn)
+PCIDevice *pci_i82559er_init(PCIBus * bus, NICInfo * nd, int devfn)
 {
-nic_init(bus, nd, "i82559er", i82559ER);
+return nic_init(bus, nd, "i82559er", i82559ER);
 }
 
 /* eof */
Index: kvm-userspace.hotplug2/qemu/hw/ne2000.c
===
--- kvm-userspace.hotplug2.orig/qemu/hw/ne2000.c
+++ kvm-userspace.hotplug2/qemu/hw/ne2000.c
@@ -786,7 +786,7 @@ static void ne2000_map(PCIDevice *pci_de
 register_ioport_read(addr + 0x1f, 1, 1, ne2000_reset_ioport_read, s);
 }
 
-void pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn)
+PCIDevice *pci_ne2000_init(PCIBus *bus, NICInfo *nd, int devfn)
 {
 PCINE2000State *d;
 NE2000State *s;
@@ -827,4 +827,6 @@ void pci_ne2000_init(PCIBus *bus, NICInf
 
 /* XXX: instance number ? */
 register_savevm("ne2000", ne2000_id++, 3, ne2000_save, ne2000_load, s);
+
+return (PCIDevice *)d;
 }
Index: kvm-userspace.hotplug2/qemu/hw/pc.h
===
--- kvm-userspace.hotplug2.orig/qemu/hw/pc.h
+++ kvm-userspace.hotplug2/qemu/hw/pc.h
@@ -146,7 +146,7 @@ void isa_ne2000_init(int base, qemu_irq 
 
 /* virtio-net.c */
 
-void *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn);
+PCIDevice *virtio_net_init(PCIBus *bus, NICInfo *nd, int devfn);
 void virtio_net_poll(void);
 
 /* virtio-blk.h */
Index: kvm-userspace.hotplug2/qemu/hw/pci.c
===
--- kvm-userspace.hotplug2.orig/qemu/hw/pci.c
+++ kvm-userspace.hotplug2/qemu/hw/pci.c
@@ -625,24 +625,26 @@ void pci_info(void)
 }
 
 /* Initialize a PCI NIC.  */
-void pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn)
+PCIDevice *pci_nic_init(PCIBus *bus, NICInfo *nd, int devfn)
 {
+PCIDevice *pci_dev;
+
 if (strcmp(nd->model, "ne2k_pci") == 0) {
-pci_ne2000_init(bus, nd, devfn);
+pci_dev = pci_ne2000_init(bus, nd, devfn);
 } else if (strcmp(nd->model, "i82551") == 0) {
-pci_i82551_init(bus, nd, devfn);
+pci_dev = pci_i82551_init(bus, nd, devfn);
 } else if (strcmp(nd->model, "i82557b") == 0) {
-pci_i82557b_init(bus, nd, devfn);
+pci_dev = pci_i82557b_init(bus, nd, devfn);
 } else if (strcmp(nd->model, "i82559er") == 0) {
-pci_i82559er_init(bus, nd, devfn);
+pci_dev = pci_i82559er_init(bus, nd, devfn);
 } else if (strcmp(nd->model, "rtl8139") == 0) {
-pci_rtl8139_init(bus, nd, devfn);
+pci_dev = pci_rtl8139_init(bus, nd, devfn);
 } else if (strcmp(nd->model, "e1000") == 0) {
-pci_e1000_init(bus, nd, devfn);
+pci_dev = pci_e1000_init(bus, nd, devfn);
 } else if (strcmp(nd->model, "pcnet") == 0) {
-pci_pcnet_init(bus, nd, devfn);
+  

[kvm-devel] [patch 07/24] QEMU/KVM: dynamic nic info index allocation

2008-03-11 Thread Marcelo Tosatti
The same, but for nics.

Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>

Index: kvm-userspace.hotplug2/qemu/net.h
===
--- kvm-userspace.hotplug2.orig/qemu/net.h
+++ kvm-userspace.hotplug2/qemu/net.h
@@ -46,6 +46,7 @@ struct NICInfo {
 const char *model;
 VLANState *vlan;
 int devfn;
+int used;
 };
 
 extern int nb_nics;
Index: kvm-userspace.hotplug2/qemu/vl.c
===
--- kvm-userspace.hotplug2.orig/qemu/vl.c
+++ kvm-userspace.hotplug2/qemu/vl.c
@@ -4791,6 +4791,15 @@ static int check_params(char *buf, int b
 return 0;
 }
 
+static int nic_get_free_idx(void)
+{
+int index;
+
+for (index = 0; index < MAX_NICS; index++)
+if (!nd_table[index].used)
+return index;
+return -1;
+}
 
 static int net_client_init(const char *str)
 {
@@ -4823,19 +4832,20 @@ static int net_client_init(const char *s
 if (!strcmp(device, "nic")) {
 NICInfo *nd;
 uint8_t *macaddr;
+int idx = nic_get_free_idx();
 
-if (nb_nics >= MAX_NICS) {
+if (idx == -1 || nb_nics >= MAX_NICS) {
 fprintf(stderr, "Too Many NICs\n");
 return -1;
 }
-nd = &nd_table[nb_nics];
+nd = &nd_table[idx];
 macaddr = nd->macaddr;
 macaddr[0] = 0x52;
 macaddr[1] = 0x54;
 macaddr[2] = 0x00;
 macaddr[3] = 0x12;
 macaddr[4] = 0x34;
-macaddr[5] = 0x56 + nb_nics;
+macaddr[5] = 0x56 + idx;
 
 if (get_param_value(buf, sizeof(buf), "macaddr", p)) {
 if (parse_macaddr(macaddr, buf) < 0) {
@@ -4847,6 +4857,7 @@ static int net_client_init(const char *s
 nd->model = strdup(buf);
 }
 nd->vlan = vlan;
+nd->used = 1;
 nb_nics++;
 vlan->nb_guest_devs++;
 ret = 0;

-- 


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [patch 09/24] QEMU/KVM: record devfn on block driver instance

2008-03-11 Thread Marcelo Tosatti
Record devfn on the BlockDriverState structure to locate for release 
on hot-removal.

Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>

Index: kvm-userspace.hotplug2/qemu/block_int.h
===
--- kvm-userspace.hotplug2.orig/qemu/block_int.h
+++ kvm-userspace.hotplug2/qemu/block_int.h
@@ -129,6 +129,8 @@ struct BlockDriverState {
 int cyls, heads, secs, translation;
 int type;
 char device_name[32];
+/* PCI devfn of parent */
+int devfn;
 BlockDriverState *next;
 };
 
Index: kvm-userspace.hotplug2/qemu/hw/lsi53c895a.c
===
--- kvm-userspace.hotplug2.orig/qemu/hw/lsi53c895a.c
+++ kvm-userspace.hotplug2/qemu/hw/lsi53c895a.c
@@ -13,6 +13,7 @@
 #include "hw.h"
 #include "pci.h"
 #include "scsi-disk.h"
+#include "block_int.h"
 
 //#define DEBUG_LSI
 //#define DEBUG_LSI_REG
@@ -1845,6 +1846,7 @@ void lsi_scsi_attach(void *opaque, Block
 s->scsi_dev[id] = scsi_generic_init(bd, 1, lsi_command_complete, s);
 if (s->scsi_dev[id] == NULL)
 s->scsi_dev[id] = scsi_disk_init(bd, 1, lsi_command_complete, s);
+bd->devfn = s->pci_dev.devfn;
 }
 
 void *lsi_scsi_init(PCIBus *bus, int devfn)
Index: kvm-userspace.hotplug2/qemu/hw/virtio-blk.c
===
--- kvm-userspace.hotplug2.orig/qemu/hw/virtio-blk.c
+++ kvm-userspace.hotplug2/qemu/hw/virtio-blk.c
@@ -13,6 +13,7 @@
 
 #include "virtio.h"
 #include "block.h"
+#include "block_int.h"
 #include "pc.h"
 
 /* from Linux's linux/virtio_blk.h */
@@ -156,6 +157,7 @@ void *virtio_blk_init(PCIBus *bus, uint1
 s->vdev.update_config = virtio_blk_update_config;
 s->vdev.get_features = virtio_blk_get_features;
 s->bs = bs;
+bs->devfn = s->vdev.pci_dev.devfn;
 
 virtio_add_queue(&s->vdev, 128, virtio_blk_handle_output);
 
Index: kvm-userspace.hotplug2/qemu/hw/ide.c
===
--- kvm-userspace.hotplug2.orig/qemu/hw/ide.c
+++ kvm-userspace.hotplug2/qemu/hw/ide.c
@@ -28,6 +28,7 @@
 #include "scsi-disk.h"
 #include "pcmcia.h"
 #include "block.h"
+#include "block_int.h"
 #include "qemu-timer.h"
 #include "sysemu.h"
 #include "ppc_mac.h"
@@ -2938,6 +2939,7 @@ void pci_piix3_ide_init(PCIBus *bus, Blo
 {
 PCIIDEState *d;
 uint8_t *pci_conf;
+int i;
 
 /* register a function 1 of PIIX3 */
 d = (PCIIDEState *)pci_register_device(bus, "PIIX3 IDE",
@@ -2966,6 +2968,10 @@ void pci_piix3_ide_init(PCIBus *bus, Blo
 ide_init_ioport(&d->ide_if[0], 0x1f0, 0x3f6);
 ide_init_ioport(&d->ide_if[2], 0x170, 0x376);
 
+for (i = 0; i < 4; i++)
+if (hd_table[i])
+hd_table[i]->devfn = d->dev.devfn;
+
 register_savevm("ide", 0, 1, pci_ide_save, pci_ide_load, d);
 }
 

-- 


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [patch 12/24] QEMU/KVM: add net_client_uninit

2008-03-11 Thread Marcelo Tosatti
Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>

Index: kvm-userspace.hotplug2/qemu/net.h
===
--- kvm-userspace.hotplug2.orig/qemu/net.h
+++ kvm-userspace.hotplug2/qemu/net.h
@@ -38,6 +38,7 @@ void do_info_network(void);
 int hack_around_tap(void *opaque);
 
 int net_client_init(const char *str);
+void net_client_uninit(NICInfo *nd);
 
 /* NIC info */
 
Index: kvm-userspace.hotplug2/qemu/vl.c
===
--- kvm-userspace.hotplug2.orig/qemu/vl.c
+++ kvm-userspace.hotplug2/qemu/vl.c
@@ -4937,6 +4937,14 @@ int net_client_init(const char *str)
 return ret;
 }
 
+void net_client_uninit(NICInfo *nd)
+{
+nd->vlan->nb_guest_devs--; /* XXX: free vlan on last reference */
+nb_nics--;
+nd->used = 0;
+free(nd->model);
+}
+
 void do_info_network(void)
 {
 VLANState *vlan;

-- 


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [patch 11/24] QEMU/KVM: net/drive add/remove tweaks

2008-03-11 Thread Marcelo Tosatti
Export net/drive add/remove functions for device hotplug usage.

Return the table index on add.

Return failure instead of exiting if limit has been reached 
on drive_add.

Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>

Index: kvm-userspace.hotplug2/qemu/vl.c
===
--- kvm-userspace.hotplug2.orig/qemu/vl.c
+++ kvm-userspace.hotplug2/qemu/vl.c
@@ -4797,7 +4797,7 @@ static int nic_get_free_idx(void)
 return -1;
 }
 
-static int net_client_init(const char *str)
+int net_client_init(const char *str)
 {
 const char *p;
 char *q;
@@ -4856,7 +4856,7 @@ static int net_client_init(const char *s
 nd->used = 1;
 nb_nics++;
 vlan->nb_guest_devs++;
-ret = 0;
+ret = idx;
 } else
 if (!strcmp(device, "none")) {
 /* does nothing. It is needed to signal that no network cards
@@ -4986,14 +4986,14 @@ static int drive_get_free_idx(void)
 return -1;
 }
 
-static int drive_add(const char *file, const char *fmt, ...)
+int drive_add(const char *file, const char *fmt, ...)
 {
 va_list ap;
 int index = drive_opt_get_free_idx();
 
 if (nb_drives_opt >= MAX_DRIVES || index == -1) {
 fprintf(stderr, "qemu: too many drives\n");
-exit(1);
+return -1;
 }
 
 drives_opt[index].file = file;
@@ -5056,9 +5056,10 @@ void drive_uninit(BlockDriverState *bdrv
 }
 }
 
-static int drive_init(struct drive_opt *arg, int snapshot,
-  QEMUMachine *machine)
+int drive_init(struct drive_opt *arg, int snapshot,
+  void *opaque)
 {
+QEMUMachine *machine = opaque;
 char buf[128];
 char file[1024];
 char devname[128];
@@ -5311,7 +5312,7 @@ static int drive_init(struct drive_opt *
  */
 
 if (drive_get_index(type, bus_id, unit_id) != -1)
-return 0;
+return -2;
 
 /* init */
 
@@ -5359,7 +5360,7 @@ static int drive_init(struct drive_opt *
 break;
 }
 if (!file[0])
-return 0;
+return -2;
 bdrv_flags = 0;
 if (snapshot)
 bdrv_flags |= BDRV_O_SNAPSHOT;
@@ -5370,7 +5371,7 @@ static int drive_init(struct drive_opt *
 file);
 return -1;
 }
-return 0;
+return drives_table_idx;
 }
 
 /***/
Index: kvm-userspace.hotplug2/qemu/net.h
===
--- kvm-userspace.hotplug2.orig/qemu/net.h
+++ kvm-userspace.hotplug2/qemu/net.h
@@ -37,6 +37,8 @@ void do_info_network(void);
 /* virtio hack for zero copy receive */
 int hack_around_tap(void *opaque);
 
+int net_client_init(const char *str);
+
 /* NIC info */
 
 #define MAX_NICS 8
Index: kvm-userspace.hotplug2/qemu/sysemu.h
===
--- kvm-userspace.hotplug2.orig/qemu/sysemu.h
+++ kvm-userspace.hotplug2/qemu/sysemu.h
@@ -166,6 +166,9 @@ struct drive_opt {
 extern struct drive_opt drives_opt[MAX_DRIVES];
 extern int nb_drives_opt;
 
+extern int drive_add(const char *file, const char *fmt, ...);
+extern int drive_init(struct drive_opt *arg, int snapshot, void *machine);
+
 /* acpi */
 void qemu_system_cpu_hot_add(int cpu, int state);
 void qemu_system_hot_add_init(char *cpu_model);

-- 


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [patch 13/24] QEMU/KVM: export get_param_value/check_params

2008-03-11 Thread Marcelo Tosatti
Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>

Index: kvm-userspace.hotplug2/qemu/sysemu.h
===
--- kvm-userspace.hotplug2.orig/qemu/sysemu.h
+++ kvm-userspace.hotplug2/qemu/sysemu.h
@@ -57,6 +57,10 @@ int qemu_live_loadvm_state(QEMUFile *f);
 
 void main_loop_wait(int timeout);
 
+int check_params(char *buf, int buf_size, char **params, const char *str);
+int get_param_value(char *buf, int buf_size, const char *tag,
+const char *str);
+
 /* Polling handling */
 
 /* return TRUE if no sleep should be done afterwards */
Index: kvm-userspace.hotplug2/qemu/vl.c
===
--- kvm-userspace.hotplug2.orig/qemu/vl.c
+++ kvm-userspace.hotplug2/qemu/vl.c
@@ -4737,8 +4737,8 @@ static const char *get_opt_value(char *b
 return p;
 }
 
-static int get_param_value(char *buf, int buf_size,
-   const char *tag, const char *str)
+int get_param_value(char *buf, int buf_size,
+const char *tag, const char *str)
 {
 const char *p;
 char option[128];
@@ -4762,8 +4762,8 @@ static int get_param_value(char *buf, in
 return 0;
 }
 
-static int check_params(char *buf, int buf_size,
-char **params, const char *str)
+int check_params(char *buf, int buf_size,
+ char **params, const char *str)
 {
 const char *p;
 int i;

-- 


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [patch 10/24] QEMU/KVM: move drives_opt for external use

2008-03-11 Thread Marcelo Tosatti
Device hotplug will use that structure from a separate
file.

Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>

Index: kvm-userspace.hotplug2/qemu/sysemu.h
===
--- kvm-userspace.hotplug2.orig/qemu/sysemu.h
+++ kvm-userspace.hotplug2/qemu/sysemu.h
@@ -157,6 +157,15 @@ extern int drive_get_max_bus(BlockInterf
 extern void drive_uninit(BlockDriverState *bdrv);
 extern void drive_remove(int index);
 
+struct drive_opt {
+const char *file;
+char opt[1024];
+int used;
+};
+
+extern struct drive_opt drives_opt[MAX_DRIVES];
+extern int nb_drives_opt;
+
 /* acpi */
 void qemu_system_cpu_hot_add(int cpu, int state);
 void qemu_system_hot_add_init(char *cpu_model);
Index: kvm-userspace.hotplug2/qemu/vl.c
===
--- kvm-userspace.hotplug2.orig/qemu/vl.c
+++ kvm-userspace.hotplug2/qemu/vl.c
@@ -251,11 +251,7 @@ unsigned int nb_prom_envs = 0;
 const char *prom_envs[MAX_PROM_ENVS];
 #endif
 int nb_drives_opt;
-struct drive_opt {
-const char *file;
-char opt[1024];
-int used;
-} drives_opt[MAX_DRIVES];
+struct drive_opt drives_opt[MAX_DRIVES];
 
 static CPUState *cur_cpu;
 static CPUState *next_cpu;

-- 


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [patch 14/24] QEMU/KVM: add pci_find_device

2008-03-11 Thread Marcelo Tosatti
Return PCIDevice from bus number and slot.

Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>

Index: kvm-userspace.hotplug/qemu/hw/pci.c
===
--- kvm-userspace.hotplug.orig/qemu/hw/pci.c
+++ kvm-userspace.hotplug/qemu/hw/pci.c
@@ -689,6 +689,23 @@ PCIBus *pci_find_bus(int bus_num)
 return bus;
 }
 
+PCIDevice *pci_find_device(int bus_num, int slot)
+{
+int devfn;
+PCIDevice *d;
+PCIBus *bus = pci_find_bus(bus_num);
+
+if (!bus)
+return NULL;
+
+for(devfn = 0; devfn < 256; devfn++) {
+d = bus->devices[devfn];
+if (d && PCI_SLOT(devfn) == slot)
+return d;
+}
+return NULL;
+}
+
 PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint32_t id,
 pci_map_irq_fn map_irq, const char *name)
 {
Index: kvm-userspace.hotplug/qemu/hw/pci.h
===
--- kvm-userspace.hotplug.orig/qemu/hw/pci.h
+++ kvm-userspace.hotplug/qemu/hw/pci.h
@@ -93,6 +93,7 @@ uint32_t pci_data_read(void *opaque, uin
 int pci_bus_num(PCIBus *s);
 void pci_for_each_device(int bus_num, void (*fn)(PCIDevice *d));
 PCIBus *pci_find_bus(int bus_num);
+PCIDevice *pci_find_device(int bus_num, int slot);
 
 void pci_info(void);
 PCIBus *pci_bridge_init(PCIBus *bus, int devfn, uint32_t id,

-- 


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [patch 15/24] QEMU/KVM: virtio_blk_init return PCIDevice pointer

2008-03-11 Thread Marcelo Tosatti
Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>

Index: kvm-userspace.hotplug2/qemu/hw/virtio-blk.c
===
--- kvm-userspace.hotplug2.orig/qemu/hw/virtio-blk.c
+++ kvm-userspace.hotplug2/qemu/hw/virtio-blk.c
@@ -161,5 +161,5 @@ void *virtio_blk_init(PCIBus *bus, uint1
 
 virtio_add_queue(&s->vdev, 128, virtio_blk_handle_output);
 
-return &s->vdev;
+return s;
 }

-- 


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [patch 17/24] QEMU/KVM: add cpu_unregister_io_memory and make io mem table index dynamic

2008-03-11 Thread Marcelo Tosatti
So drivers can clear their mem io table entries on exit back to unassigned 
state.

Also make the io mem index allocation dynamic. 

Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>

Index: kvm-userspace.hotplug2/qemu/cpu-all.h
===
--- kvm-userspace.hotplug2.orig/qemu/cpu-all.h
+++ kvm-userspace.hotplug2/qemu/cpu-all.h
@@ -837,6 +837,7 @@ int cpu_register_io_memory(int io_index,
CPUReadMemoryFunc **mem_read,
CPUWriteMemoryFunc **mem_write,
void *opaque);
+void cpu_unregister_io_memory(int table_address);
 CPUWriteMemoryFunc **cpu_get_io_memory_write(int io_index);
 CPUReadMemoryFunc **cpu_get_io_memory_read(int io_index);
 
Index: kvm-userspace.hotplug2/qemu/exec.c
===
--- kvm-userspace.hotplug2.orig/qemu/exec.c
+++ kvm-userspace.hotplug2/qemu/exec.c
@@ -158,7 +158,7 @@ PhysPageDesc **l1_phys_map;
 CPUWriteMemoryFunc *io_mem_write[IO_MEM_NB_ENTRIES][4];
 CPUReadMemoryFunc *io_mem_read[IO_MEM_NB_ENTRIES][4];
 void *io_mem_opaque[IO_MEM_NB_ENTRIES];
-static int io_mem_nb;
+char io_mem_used[IO_MEM_NB_ENTRIES];
 #if defined(CONFIG_SOFTMMU)
 static int io_mem_watch;
 #endif
@@ -2498,12 +2498,28 @@ static void *subpage_init (target_phys_a
 return mmio;
 }
 
+static int get_free_io_mem_idx(void)
+{
+int i;
+
+for (i = 0; i> IO_MEM_SHIFT, error_mem_read, 
unassigned_mem_write, NULL);
 cpu_register_io_memory(IO_MEM_UNASSIGNED >> IO_MEM_SHIFT, 
unassigned_mem_read, unassigned_mem_write, NULL);
 cpu_register_io_memory(IO_MEM_NOTDIRTY >> IO_MEM_SHIFT, error_mem_read, 
notdirty_mem_write, NULL);
-io_mem_nb = 5;
+for (i=0; i<5; i++)
+io_mem_used[i] = 0;
 
 #if defined(CONFIG_SOFTMMU)
 io_mem_watch = cpu_register_io_memory(-1, watch_mem_read,
@@ -2530,9 +2546,9 @@ int cpu_register_io_memory(int io_index,
 int i, subwidth = 0;
 
 if (io_index <= 0) {
-if (io_mem_nb >= IO_MEM_NB_ENTRIES)
-return -1;
-io_index = io_mem_nb++;
+io_index = get_free_io_mem_idx();
+if (io_index == -1)
+return io_index;
 } else {
 if (io_index >= IO_MEM_NB_ENTRIES)
 return -1;
@@ -2548,6 +2564,19 @@ int cpu_register_io_memory(int io_index,
 return (io_index << IO_MEM_SHIFT) | subwidth;
 }
 
+void cpu_unregister_io_memory(int io_table_address)
+{
+int i;
+int io_index = io_table_address >> IO_MEM_SHIFT;
+
+for (i=0;i < 3; i++) {
+io_mem_read[io_index][i] = unassigned_mem_read[i];
+io_mem_write[io_index][i] = unassigned_mem_write[i];
+}
+io_mem_opaque[io_index] = NULL;
+io_mem_used[io_index] = 0;
+}
+
 CPUWriteMemoryFunc **cpu_get_io_memory_write(int io_index)
 {
 return io_mem_write[io_index >> IO_MEM_SHIFT];

-- 


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [patch 16/24] QEMU/KVM: device and disk hot-add

2008-03-11 Thread Marcelo Tosatti
Add monitor command to hot-add PCI devices (nic and storage).

Syntax is:

pci_add pcibus nic|storage params

It returns the bus slot and function for the newly added device on success.

It is possible to attach a disk to a device after PCI initialization via
the drive_add command. If so, a manual scan of the SCSI bus on the guest 
is necessary.

Save QEMUMachine necessary for drive_init.

Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>

Index: kvm-userspace.hotplug2/qemu/Makefile.target
===
--- kvm-userspace.hotplug2.orig/qemu/Makefile.target
+++ kvm-userspace.hotplug2/qemu/Makefile.target
@@ -579,6 +579,8 @@ OBJS+= hypercall.o
 # virtio devices
 OBJS += virtio.o virtio-net.o virtio-blk.o
 
+OBJS += device-hotplug.o
+
 ifeq ($(TARGET_BASE_ARCH), i386)
 # Hardware support
 OBJS+= ide.o pckbd.o ps2.o vga.o $(SOUND_HW) dma.o
Index: kvm-userspace.hotplug2/qemu/hw/device-hotplug.c
===
--- /dev/null
+++ kvm-userspace.hotplug2/qemu/hw/device-hotplug.c
@@ -0,0 +1,158 @@
+#include "hw.h"
+#include "boards.h"
+#include "pci.h"
+#include "net.h"
+#include "sysemu.h"
+#include "pc.h"
+#include "console.h"
+
+static PCIDevice *qemu_system_hot_add_nic(const char *opts, int bus_nr)
+{
+int ret;
+char buf[4096];
+PCIBus *pci_bus;
+
+pci_bus = pci_find_bus (bus_nr);
+if (!pci_bus) {
+term_printf ("Can't find pci_bus %d\n", bus_nr);
+return NULL;
+}
+
+memset (buf, 0, sizeof (buf));
+
+strcpy (buf, "nic,");
+strncat (buf, opts, sizeof (buf) - strlen (buf) - 1);
+
+ret = net_client_init (buf);
+if (ret < 0 || !nd_table[ret].model)
+return NULL;
+return pci_nic_init (pci_bus, &nd_table[ret], -1);
+}
+
+static int add_init_drive(const char *opts)
+{
+int drive_opt_idx, drive_idx;
+int ret = -1;
+
+drive_opt_idx = drive_add(NULL, "%s", opts);
+if (!drive_opt_idx)
+return ret;
+
+drive_idx = drive_init(&drives_opt[drive_opt_idx], 0, current_machine);
+if (drive_idx == -1) {
+drive_remove(drive_opt_idx);
+return ret;
+}
+
+return drive_idx;
+}
+
+void drive_hot_add(int pcibus, const char *devfn_string, const char *opts)
+{
+int drive_idx, type, bus;
+int devfn;
+int success = 0;
+PCIDevice *dev;
+
+devfn = strtoul(devfn_string, NULL, 0);
+
+dev = pci_find_device(pcibus, PCI_SLOT(devfn));
+if (!dev) {
+term_printf("no pci device with devfn %d (slot %d)\n", devfn,
+PCI_SLOT(devfn));
+return;
+}
+
+drive_idx = add_init_drive(opts);
+if (drive_idx < 0)
+return;
+type = drives_table[drive_idx].type;
+bus = drive_get_max_bus (type);
+
+switch (type) {
+case IF_SCSI:
+success = 1;
+lsi_scsi_attach (dev, drives_table[drive_idx].bdrv,
+ drives_table[drive_idx].unit);
+break;
+default:
+term_printf("Can't hot-add drive to type %d\n", type);
+}
+
+if (success)
+term_printf("OK bus %d, unit %d\n", drives_table[drive_idx].bus,
+drives_table[drive_idx].unit);
+return;
+}
+
+static PCIDevice *qemu_system_hot_add_storage(const char *opts, int bus_nr)
+{
+void *opaque = NULL;
+PCIBus *pci_bus;
+int type = -1, drive_idx = -1;
+char buf[128];
+
+pci_bus = pci_find_bus(bus_nr);
+if (!pci_bus) {
+term_printf("Can't find pci_bus %d\n", bus_nr);
+return NULL;
+}
+
+if (get_param_value(buf, sizeof(buf), "if", opts)) {
+if (!strcmp(buf, "scsi"))
+type = IF_SCSI;
+else if (!strcmp(buf, "virtio")) {
+type = IF_VIRTIO;
+}
+} else {
+term_printf("no if= specified\n");
+return NULL;
+}
+
+if (get_param_value(buf, sizeof(buf), "file", opts)) {
+drive_idx = add_init_drive(opts);
+if (drive_idx < 0)
+return NULL;
+} else if (type == IF_VIRTIO) {
+term_printf("virtio requires a backing file/device.\n");
+return NULL;
+}
+
+switch (type) {
+case IF_SCSI:
+opaque = lsi_scsi_init (pci_bus, -1);
+if (drive_idx >= 0)
+lsi_scsi_attach (opaque, drives_table[drive_idx].bdrv,
+ drives_table[drive_idx].unit);
+break;
+case IF_VIRTIO:
+opaque = virtio_blk_init (pci_bus, 0x1AF4, 0x1001,
+  drives_table[drive_idx].bdrv);
+break;
+default:
+term_printf ("type %s not a hotpluggable PCI device.\n", buf);
+}
+
+return opaque;
+}
+
+void device_hot_add(int pcibus, const char *type, const char *opts)
+{
+PCIDevice *dev = NULL;
+
+if (strcmp(type, "nic") == 0)
+dev = qemu_system_hot_add_nic(opts, pcibus);
+else if (strcmp(type, "storage") == 0)
+dev = qemu_system_hot

[kvm-devel] [patch 18/24] QEMU/KVM: notify _EJ0 through _SEJ OperationRegion

2008-03-11 Thread Marcelo Tosatti
The _EJ0 method is executed by the OS once it has successfully finished
device removal. Inform that event through IO port space so QEMU 
can free the associated data.

Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>

Index: kvm-userspace.hotplug2/bios/acpi-dsdt.dsl
===
--- kvm-userspace.hotplug2.orig/bios/acpi-dsdt.dsl
+++ kvm-userspace.hotplug2/bios/acpi-dsdt.dsl
@@ -414,159 +414,258 @@ DefinitionBlock (
PCID, 32,
}
 
+OperationRegion(SEJ, SystemIO, 0xae08, 0x04)
+Field (SEJ, DWordAcc, NoLock, WriteAsZeros)
+{
+B0EJ, 32,
+}
+
 Device (S1) {  // Slot 1
Name (_ADR, 0x0001)
-   Method (_EJ0,1) { Return (0x0) }
+   Method (_EJ0,1) {
+Store(0x2, B0EJ)
+Return (0x0)
+   }
 }
 
 Device (S2) {  // Slot 2
Name (_ADR, 0x0002)
-   Method (_EJ0,1) { Return (0x0) }
+   Method (_EJ0,1) {
+Store(0x4, B0EJ)
+Return (0x0)
+   }
 }
 
 Device (S3) {  // Slot 3
Name (_ADR, 0x0003)
-   Method (_EJ0,1) { Return (0x0) }
+   Method (_EJ0,1) {
+Store (0x8, B0EJ)
+Return (0x0)
+   }
 }
 
 Device (S4) {  // Slot 4
Name (_ADR, 0x0004)
-   Method (_EJ0,1) { Return (0x0) }
+   Method (_EJ0,1) {
+Store(0x10, B0EJ)
+Return (0x0)
+   }
 }
 
 Device (S5) {  // Slot 5
Name (_ADR, 0x0005)
-   Method (_EJ0,1) { Return (0x0) }
+   Method (_EJ0,1) {
+Store(0x20, B0EJ)
+Return (0x0)
+   }
 }
 
 Device (S6) {  // Slot 6
Name (_ADR, 0x0006)
-   Method (_EJ0,1) { Return (0x0) }
+   Method (_EJ0,1) {
+Store(0x40, B0EJ)
+Return (0x0)
+   }
 }
 
 Device (S7) {  // Slot 7
Name (_ADR, 0x0007)
-   Method (_EJ0,1) { Return (0x0) }
+   Method (_EJ0,1) {
+Store(0x80, B0EJ)
+Return (0x0)
+   }
 }
 
 Device (S8) {  // Slot 8
Name (_ADR, 0x0008)
-   Method (_EJ0,1) { Return (0x0) }
+   Method (_EJ0,1) {
+Store(0x100, B0EJ)
+Return (0x0)
+   }
 }
 
 Device (S9) {  // Slot 9
Name (_ADR, 0x0009)
-   Method (_EJ0,1) { Return (0x0) }
+   Method (_EJ0,1) {
+Store(0x200, B0EJ)
+Return (0x0)
+   }
 }
 
 Device (S10) {  // Slot 10
Name (_ADR, 0x000A)
-   Method (_EJ0,1) { Return (0x0) }
+   Method (_EJ0,1) {
+Store(0x400, B0EJ)
+Return (0x0)
+   }
 }
 
 Device (S11) {  // Slot 11
Name (_ADR, 0x000B)
-   Method (_EJ0,1) { Return (0x0) }
+   Method (_EJ0,1) {
+Store(0x800, B0EJ)
+Return (0x0)
+   }
 }
 
 Device (S12) {  // Slot 12
Name (_ADR, 0x000C)
-   Method (_EJ0,1) { Return (0x0) }
+   Method (_EJ0,1) {
+Store(0x1000, B0EJ)
+Return (0x0)
+   }
 }
 
 Device (S13) {  // Slot 13
Name (_ADR, 0x000D)
-   Method (_EJ0,1) { Return (0x0) }
+   Method (_EJ0,1) {
+Store(0x2000, B0EJ)
+Return (0x0)
+   }
 }
 
 Device (S14) {  // Slot 14
Name (_ADR, 0x000E)
-   Method (_EJ0,1) { Return (0x0) }
+   Method (_EJ0,1) {
+Store(0x4000, B0EJ)
+Return (0x0)
+   }
 }
 
 Device (S15) {  // Slot 15
Name (_ADR, 0x000F)
-   Method (_EJ0,1) { Return (0x0) }
+   Method (_EJ0,1) {
+Store(0x8000, B0EJ)
+Return (0x0)
+   }
 }
 
 Device (S16) {  // Slot 16
Na

[kvm-devel] [patch 19/24] QEMU/KVM: handle SEJ notifications

2008-03-11 Thread Marcelo Tosatti
Handle the _EJ0 notifications.

Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>

Index: kvm-userspace.hotplug2/qemu/hw/acpi.c
===
--- kvm-userspace.hotplug2.orig/qemu/hw/acpi.c
+++ kvm-userspace.hotplug2/qemu/hw/acpi.c
@@ -26,6 +26,7 @@
 #ifdef USE_KVM
 #include "qemu-kvm.h"
 #endif
+#include "string.h"
 
 //#define DEBUG
 
@@ -539,6 +540,7 @@ void qemu_system_powerdown(void)
 #define GPE_BASE 0xafe0
 #define PROC_BASE 0xaf00
 #define PCI_BASE 0xae00
+#define PCI_EJ_BASE 0xae08
 
 struct gpe_regs {
 uint16_t sts; /* status */
@@ -659,6 +661,23 @@ static void pcihotplug_write(void *opaqu
 #endif
 }
 
+static uint32_t pciej_read(void *opaque, uint32_t addr)
+{
+#if defined(DEBUG)
+printf("pciej read %lx == %lx\n", addr, val);
+#endif
+return 0;
+}
+
+static void pciej_write(void *opaque, uint32_t addr, uint32_t val)
+{
+int slot = ffs(val) - 1;
+
+#if defined(DEBUG)
+printf("pciej write %lx <== %d\n", addr, val);
+#endif
+}
+
 
 static char *model;
 
@@ -673,6 +692,9 @@ void qemu_system_hot_add_init(char *cpu_
 register_ioport_write(PCI_BASE, 8, 4, pcihotplug_write, &pci0_status);
 register_ioport_read(PCI_BASE, 8, 4,  pcihotplug_read, &pci0_status);
 
+register_ioport_write(PCI_EJ_BASE, 4, 4, pciej_write, NULL);
+register_ioport_read(PCI_EJ_BASE, 4, 4,  pciej_read, NULL);
+
 model = cpu_model;
 }
 

-- 


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [patch 20/24] QEMU/KVM: add qemu_free_irqs

2008-03-11 Thread Marcelo Tosatti
Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>

Index: kvm-userspace.hotplug2/qemu/hw/irq.c
===
--- kvm-userspace.hotplug2.orig/qemu/hw/irq.c
+++ kvm-userspace.hotplug2/qemu/hw/irq.c
@@ -56,6 +56,12 @@ qemu_irq *qemu_allocate_irqs(qemu_irq_ha
 return s;
 }
 
+void qemu_free_irqs(qemu_irq *s)
+{
+qemu_free(s[0]);
+qemu_free(s);
+}
+
 static void qemu_notirq(void *opaque, int line, int level)
 {
 struct IRQState *irq = opaque;
Index: kvm-userspace.hotplug2/qemu/hw/irq.h
===
--- kvm-userspace.hotplug2.orig/qemu/hw/irq.h
+++ kvm-userspace.hotplug2/qemu/hw/irq.h
@@ -28,6 +28,8 @@ static inline void qemu_irq_pulse(qemu_i
 /* Returns an array of N IRQs.  */
 qemu_irq *qemu_allocate_irqs(qemu_irq_handler handler, void *opaque, int n);
 
+void qemu_free_irqs(qemu_irq *s);
+
 /* Returns a new IRQ with opposite polarity.  */
 qemu_irq qemu_irq_invert(qemu_irq irq);
 

-- 


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [patch 21/24] QEMU/KVM: add pci_unregister_device

2008-03-11 Thread Marcelo Tosatti
Unregister the pci device, unassign its IO and memory regions, and free
associated data.

Add a callback so drivers can free device state.

Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>

Index: kvm-userspace.hotplug2/qemu/hw/pci.c
===
--- kvm-userspace.hotplug2.orig/qemu/hw/pci.c
+++ kvm-userspace.hotplug2/qemu/hw/pci.c
@@ -185,6 +185,48 @@ PCIDevice *pci_register_device(PCIBus *b
 return pci_dev;
 }
 
+static target_phys_addr_t pci_to_cpu_addr(target_phys_addr_t addr)
+{
+return addr + pci_mem_base;
+}
+
+static void pci_unregister_io_regions(PCIDevice *pci_dev)
+{
+PCIIORegion *r;
+int i;
+
+for(i = 0; i < PCI_NUM_REGIONS; i++) {
+r = &pci_dev->io_regions[i];
+if (!r->size)
+continue;
+if (r->type == PCI_ADDRESS_SPACE_IO) {
+isa_unassign_ioport(r->addr, r->size);
+} else {
+cpu_register_physical_memory(pci_to_cpu_addr(r->addr),
+ r->size,
+ IO_MEM_UNASSIGNED);
+}
+}
+}
+
+int pci_unregister_device(PCIDevice *pci_dev)
+{
+int ret = 0;
+
+if (pci_dev->unregister)
+ret = pci_dev->unregister(pci_dev);
+if (ret)
+return ret;
+
+pci_unregister_io_regions(pci_dev);
+
+qemu_free_irqs(pci_dev->irq);
+pci_irq_index--;
+pci_dev->bus->devices[pci_dev->devfn] = NULL;
+qemu_free(pci_dev);
+return 0;
+}
+
 void pci_register_io_region(PCIDevice *pci_dev, int region_num,
 uint32_t size, int type,
 PCIMapIORegionFunc *map_func)
@@ -207,10 +249,6 @@ void pci_register_io_region(PCIDevice *p
 *(uint32_t *)(pci_dev->config + addr) = cpu_to_le32(type);
 }
 
-static target_phys_addr_t pci_to_cpu_addr(target_phys_addr_t addr)
-{
-return addr + pci_mem_base;
-}
 
 static void pci_update_mappings(PCIDevice *d)
 {
Index: kvm-userspace.hotplug2/qemu/hw/pci.h
===
--- kvm-userspace.hotplug2.orig/qemu/hw/pci.h
+++ kvm-userspace.hotplug2/qemu/hw/pci.h
@@ -15,6 +15,7 @@ typedef uint32_t PCIConfigReadFunc(PCIDe
uint32_t address, int len);
 typedef void PCIMapIORegionFunc(PCIDevice *pci_dev, int region_num,
 uint32_t addr, uint32_t size, int type);
+typedef int PCIUnregisterFunc(PCIDevice *pci_dev);
 
 #define PCI_ADDRESS_SPACE_MEM  0x00
 #define PCI_ADDRESS_SPACE_IO   0x01
@@ -56,6 +57,7 @@ struct PCIDevice {
 /* do not access the following fields */
 PCIConfigReadFunc *config_read;
 PCIConfigWriteFunc *config_write;
+PCIUnregisterFunc *unregister;
 /* ??? This is a PC-specific hack, and should be removed.  */
 int irq_index;
 
@@ -71,6 +73,8 @@ PCIDevice *pci_register_device(PCIBus *b
PCIConfigReadFunc *config_read,
PCIConfigWriteFunc *config_write);
 
+int pci_unregister_device(PCIDevice *pci_dev);
+
 void pci_register_io_region(PCIDevice *pci_dev, int region_num,
 uint32_t size, int type,
 PCIMapIORegionFunc *map_func);

-- 


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [patch 22/24] QEMU/KVM: LSI SCSI and e1000 unregister callbacks

2008-03-11 Thread Marcelo Tosatti
Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>

Index: kvm-userspace.hotplug2/qemu/hw/lsi53c895a.c
===
--- kvm-userspace.hotplug2.orig/qemu/hw/lsi53c895a.c
+++ kvm-userspace.hotplug2/qemu/hw/lsi53c895a.c
@@ -1849,6 +1849,18 @@ void lsi_scsi_attach(void *opaque, Block
 bd->devfn = s->pci_dev.devfn;
 }
 
+int lsi_scsi_uninit(PCIDevice *d)
+{
+LSIState *s = (LSIState *) d;
+
+cpu_unregister_io_memory(s->mmio_io_addr);
+cpu_unregister_io_memory(s->ram_io_addr);
+
+qemu_free(s->queue);
+
+return 0;
+}
+
 void *lsi_scsi_init(PCIBus *bus, int devfn)
 {
 LSIState *s;
@@ -1881,6 +1893,7 @@ void *lsi_scsi_init(PCIBus *bus, int dev
 s->queue = qemu_malloc(sizeof(lsi_queue));
 s->queue_len = 1;
 s->active_commands = 0;
+s->pci_dev.unregister = lsi_scsi_uninit;
 
 lsi_soft_reset(s);
 
Index: kvm-userspace.hotplug2/qemu/hw/e1000.c
===
--- kvm-userspace.hotplug2.orig/qemu/hw/e1000.c
+++ kvm-userspace.hotplug2/qemu/hw/e1000.c
@@ -930,6 +930,16 @@ e1000_mmio_map(PCIDevice *pci_dev, int r
 cpu_register_physical_memory(addr, PNPMMIO_SIZE, d->mmio_index);
 }
 
+static int
+pci_e1000_uninit(PCIDevice *dev)
+{
+E1000State *d = (E1000State *) dev;
+
+cpu_unregister_io_memory(d->mmio_index);
+
+return 0;
+}
+
 PCIDevice *
 pci_e1000_init(PCIBus *bus, NICInfo *nd, int devfn)
 {
@@ -994,6 +1004,7 @@ pci_e1000_init(PCIBus *bus, NICInfo *nd,
  d->nd->macaddr[3], d->nd->macaddr[4], d->nd->macaddr[5]);
 
 register_savevm(info_str, d->instance, 1, nic_save, nic_load, d);
+d->dev.unregister = pci_e1000_uninit;
 
 return (PCIDevice *)d;
 }

-- 


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [patch 23/24] QEMU/KVM: zero ioport_opaque on isa_unassign_ioport

2008-03-11 Thread Marcelo Tosatti
If the io port is unassigned, the previous private pointer is 
meaningless.

Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>

Index: kvm-userspace.hotplug2/qemu/vl.c
===
--- kvm-userspace.hotplug2.orig/qemu/vl.c
+++ kvm-userspace.hotplug2/qemu/vl.c
@@ -399,6 +399,8 @@ void isa_unassign_ioport(int start, int 
 ioport_write_table[0][i] = default_ioport_writeb;
 ioport_write_table[1][i] = default_ioport_writew;
 ioport_write_table[2][i] = default_ioport_writel;
+
+ioport_opaque[i] = NULL;
 }
 }
 

-- 


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [patch 24/24] QEMU/KVM: device hot-remove

2008-03-11 Thread Marcelo Tosatti
Add monitor command to hot-remove devices.

Remove device data on _EJ0 notification.

Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>

Index: kvm-userspace.hotplug2/qemu/monitor.c
===
--- kvm-userspace.hotplug2.orig/qemu/monitor.c
+++ kvm-userspace.hotplug2/qemu/monitor.c
@@ -1365,6 +1365,7 @@ static term_cmd_t term_cmds[] = {
 "[snapshot=on|off][,cache=on|off]",
 "add drive to PCI storage controller" 
},
 { "pci_add", "iss", device_hot_add, "bus nic|storage 
[[vlan=n][,macaddr=addr][,model=type]] [file=file][,if=type][,bus=nr]...", 
"hot-add PCI device" },
+{ "pci_del", "ii", device_hot_remove, "bus slot-number", "hot remove PCI 
device" },
 { NULL, NULL, },
 };
 
Index: kvm-userspace.hotplug2/qemu/hw/device-hotplug.c
===
--- kvm-userspace.hotplug2.orig/qemu/hw/device-hotplug.c
+++ kvm-userspace.hotplug2/qemu/hw/device-hotplug.c
@@ -5,6 +5,8 @@
 #include "sysemu.h"
 #include "pc.h"
 #include "console.h"
+#include "block_int.h"
+#include 
 
 static PCIDevice *qemu_system_hot_add_nic(const char *opts, int bus_nr)
 {
@@ -148,7 +150,7 @@ void device_hot_add(int pcibus, const ch
 term_printf("invalid type: %s\n", type);
 
 if (dev) {
-qemu_system_device_hot_add(PCI_SLOT(dev->devfn), 1);
+qemu_system_device_hot_add(pcibus, PCI_SLOT(dev->devfn), 1);
 term_printf("OK bus %d, slot %d, function %d (devfn %d)\n",
 pci_bus_num(dev->bus), PCI_SLOT(dev->devfn),
 PCI_FUNC(dev->devfn), dev->devfn);
@@ -156,3 +158,67 @@ void device_hot_add(int pcibus, const ch
 term_printf("failed to add %s\n", opts);
 }
 
+void device_hot_remove(int pcibus, int slot)
+{
+PCIDevice *d = pci_find_device(pcibus, slot);
+
+if (!d) {
+term_printf("invalid slot %d\n", slot);
+return;
+}
+
+qemu_system_device_hot_add(pcibus, slot, 0);
+}
+
+static void destroy_nic(int slot)
+{
+int i;
+
+for (i = 0; i < MAX_NICS; i++)
+if (nd_table[i].used &&
+PCI_SLOT(nd_table[i].devfn) == slot)
+net_client_uninit(&nd_table[i]);
+}
+
+static void destroy_bdrvs(int slot)
+{
+int i;
+struct BlockDriverState *bs;
+
+for (i = 0; i <= MAX_DRIVES; i++) {
+bs = drives_table[i].bdrv;
+if (bs && (PCI_SLOT(bs->devfn) == slot)) {
+drive_uninit(bs);
+bdrv_delete(bs);
+}
+}
+}
+
+/*
+ * OS has executed _EJ0 method, we now can remove the device
+ */
+void device_hot_remove_success(int pcibus, int slot)
+{
+PCIDevice *d = pci_find_device(pcibus, slot);
+int class_code;
+
+if (!d) {
+term_printf("invalid slot %d\n", slot);
+return;
+}
+
+class_code = d->config_read(d, PCI_CLASS_DEVICE+1, 1);
+
+pci_unregister_device(d);
+
+switch(class_code) {
+case PCI_BASE_CLASS_STORAGE:
+destroy_bdrvs(slot);
+break;
+case PCI_BASE_CLASS_NETWORK:
+destroy_nic(slot);
+break;
+}
+
+}
+
Index: kvm-userspace.hotplug2/qemu/sysemu.h
===
--- kvm-userspace.hotplug2.orig/qemu/sysemu.h
+++ kvm-userspace.hotplug2/qemu/sysemu.h
@@ -176,11 +176,13 @@ extern int drive_init(struct drive_opt *
 /* acpi */
 void qemu_system_cpu_hot_add(int cpu, int state);
 void qemu_system_hot_add_init(char *cpu_model);
-void qemu_system_device_hot_add(int slot, int state);
+void qemu_system_device_hot_add(int pcibus, int slot, int state);
 
 /* device-hotplug */
 void device_hot_add(int pcibus, const char *type, const char *opts);
 void drive_hot_add(int pcibus, const char *devfn_string, const char *opts);
+void device_hot_remove(int pcibus, int slot);
+void device_hot_remove_success(int pcibus, int slot);
 
 /* vmchannel devices */
 
Index: kvm-userspace.hotplug2/qemu/hw/acpi.c
===
--- kvm-userspace.hotplug2.orig/qemu/hw/acpi.c
+++ kvm-userspace.hotplug2/qemu/hw/acpi.c
@@ -673,6 +673,8 @@ static void pciej_write(void *opaque, ui
 {
 int slot = ffs(val) - 1;
 
+device_hot_remove_success(0, slot);
+
 #if defined(DEBUG)
 printf("pciej write %lx <== %d\n", addr, val);
 #endif
@@ -751,7 +753,7 @@ static void disable_device(struct pci_st
 p->down |= (1 << slot);
 }
 
-void qemu_system_device_hot_add(int slot, int state)
+void qemu_system_device_hot_add(int pcibus, int slot, int state)
 {
 qemu_set_irq(pm_state->irq, 1);
 pci0_status.up = 0;

-- 


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@l

[kvm-devel] [PATCH] Move kvm_get_pit to libkvm.c common code

2008-03-11 Thread Jerone Young
# HG changeset patch
# User Jerone Young <[EMAIL PROTECTED]>
# Date 1205266548 18000
# Branch merge
# Node ID b136c0450c0f7c6ff2262437b1beb9896b1585e3
# Parent  c14fbbaee36241aa0fab0d6391e47cf9f4ac8012
Move kvm_get_pit to libkvm.c common code

This fixes compilation issues for PowerPC and other non x86 archs that do not
have in kernel pit. The pit code is added into the kvm_context in kvm-common.h 
&the error causing the issue is coming from a definition in qemu. This seems to 
be the proper fix as there is also a common function:
kvm_irqchip_in_kernel
for in kernel irq that handles this the same way.

Signed-off-by: Jerone Young <[EMAIL PROTECTED]>

diff --git a/libkvm/libkvm-x86.c b/libkvm/libkvm-x86.c
--- a/libkvm/libkvm-x86.c
+++ b/libkvm/libkvm-x86.c
@@ -660,12 +660,3 @@ int kvm_disable_tpr_access_reporting(kvm
 }
 
 #endif
-
-int kvm_pit_in_kernel(kvm_context_t kvm)
-{
-#ifdef KVM_CAP_PIT
-   return kvm->pit_in_kernel;
-#else
-   return 0;
-#endif
-}
diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
--- a/libkvm/libkvm.c
+++ b/libkvm/libkvm.c
@@ -962,3 +962,8 @@ int kvm_irqchip_in_kernel(kvm_context_t 
 {
 return kvm->irqchip_in_kernel;
 }
+
+int kvm_pit_in_kernel(kvm_context_t kvm)
+{
+   return kvm->pit_in_kernel;
+}
diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h
--- a/libkvm/libkvm.h
+++ b/libkvm/libkvm.h
@@ -530,6 +530,13 @@ int kvm_set_lapic(kvm_context_t kvm, int
 
 #endif
 
+/*!
+ * \brief Query wheather in kernel pit is used
+ *
+ *  \param kvm Pointer to the current kvm_context
+ */
+int kvm_pit_in_kernel(kvm_context_t kvm);
+
 #ifdef KVM_CAP_PIT
 
 /*!

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [patch 08/24] QEMU/KVM: drive removal support

2008-03-11 Thread Marcelo Tosatti
To be used by hot-remove.

Signed-off-by: Marcelo Tosatti <[EMAIL PROTECTED]>

Index: kvm-userspace.hotplug2/qemu/vl.c
===
--- kvm-userspace.hotplug2.orig/qemu/vl.c
+++ kvm-userspace.hotplug2/qemu/vl.c
@@ -5010,6 +5010,12 @@ static int drive_add(const char *file, c
 return index;
 }
 
+void drive_remove(int index)
+{
+drives_opt[index].used = 0;
+nb_drives_opt--;
+}
+
 int drive_get_index(BlockInterfaceType type, int bus, int unit)
 {
 int index;
@@ -5040,6 +5046,20 @@ int drive_get_max_bus(BlockInterfaceType
 return max_bus;
 }
 
+void drive_uninit(BlockDriverState *bdrv)
+{
+int i;
+
+for (i = 0; i < MAX_DRIVES; i++)
+if (drives_table[i].bdrv == bdrv) {
+drives_table[i].bdrv = NULL;
+drives_table[i].used = 0;
+drive_remove(drives_table[i].drive_opt_idx);
+nb_drives--;
+break;
+}
+}
+
 static int drive_init(struct drive_opt *arg, int snapshot,
   QEMUMachine *machine)
 {
@@ -5313,6 +5333,7 @@ static int drive_init(struct drive_opt *
 drives_table[drives_table_idx].type = type;
 drives_table[drives_table_idx].bus = bus_id;
 drives_table[drives_table_idx].unit = unit_id;
+drives_table[drives_table_idx].drive_opt_idx = arg - drives_opt;
 nb_drives++;
 
 switch(type) {
Index: kvm-userspace.hotplug2/qemu/sysemu.h
===
--- kvm-userspace.hotplug2.orig/qemu/sysemu.h
+++ kvm-userspace.hotplug2/qemu/sysemu.h
@@ -140,6 +140,7 @@ typedef struct DriveInfo {
 int bus;
 int unit;
 int used;
+int drive_opt_idx;
 } DriveInfo;
 
 #define MAX_IDE_DEVS   2
@@ -153,6 +154,9 @@ int extboot_drive;
 extern int drive_get_index(BlockInterfaceType type, int bus, int unit);
 extern int drive_get_max_bus(BlockInterfaceType type);
 
+extern void drive_uninit(BlockDriverState *bdrv);
+extern void drive_remove(int index);
+
 /* acpi */
 void qemu_system_cpu_hot_add(int cpu, int state);
 void qemu_system_hot_add_init(char *cpu_model);

-- 


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] how increase performance of network io in kvm

2008-03-11 Thread Dhirendra Pal Singh
On Mon, Mar 10, 2008 at 3:37 PM, Dor Laor <[EMAIL PROTECTED]> wrote:

>
> On Mon, 2008-03-10 at 12:13 -0700, Jorge Lucángeli Obes wrote:
> > On Mon, Mar 10, 2008 at 11:58 AM, Dhirendra Pal Singh
> > <[EMAIL PROTECTED]> wrote:
> > > Hi Guys,
> > >
> > > I am trying to evaluate, kvm at my work for virtual support in our
> product..
> > >
> > > I had setup up a windows guest, in my ubuntu host, on hardware with
> Intel VT
> > > support.
> > >
> > > Now when I try to download a 1 GB file present, inside windows virtual
> > > machine, using samba, from a another linux box, I get the following...
> > >
> > >
> > > a) time when coping from windows in kvm
> > >
> > > linux:~/tmp # time cp /media/hdisk/1GB_text.txt .
> > >
> > > real6m36.478s
> > >
> > > user0m0.060s
> > >
> > > sys 0m8.293s
> > >
> > > linux:~/tmp #
> > >
> > >
> > > b) time when coping from linux native..
> > >
> > >  linux:~/tmp/tmp # time cp /media/hdisk/1GB_text .
> > >
> > > real0m49.501s
> > >
> > > user0m0.040s
> > >
> > > sys 0m8.657s
> > >
> > > linux:~/tmp/tmp #
> > >
> > >
> > > So its like 50second (linux native) Vs 6+minutes(windows guest in
> KVM),
> > > which is huge.
> > >
> > > This is using user based networking, where I am just forwarding all
> the
> > > netbios ports from host to guest.
> > >
> > >  Are there any links, pointers, faqs, ideas , suggestions I could try
> out to
> > > increase the performance of this kvm virtual machine? Will using
> public
> > > bridge (option 3), as described on page
> > > http://kvm.qumranet.com/kvmwiki/Networking help?
> >
> > Most probably. When I was trying VMGL
> > (http://www.cs.toronto.edu/~andreslc/xen-gl/)
> in KVM I got a 20-fold
> > increase in performance when I switched from usermode networking to
> > the tap/bridge approach. Definitely try it. I assume you are forced to
> > use a Windows guest, but if not you might also want to try virtio
> > (http://kvm.qumranet.com/kvmwiki/Virtio).
> >
>
>
> We published virtio network drivers for Linux but not yet for Windows.
> Our virtio drivers for windows are almost done (for rev#1), we'll surely
> release the binaries for them.
>
> In the mean time you can use e1000 nic device & driver. It has the best
> results among the emulated devices and even close to virtio performance.
>
> Regards,
> Dor
>

Thanks a lot for your help.. man

So, the performance numbers with public bridge, actually increases the
performance by many folds. Now I can copy the same 1 gb file in 1.30 mins..
which is awesome.

Now a dumb question (sorry :( ), but how do I use e1000 nic device and
driver. -net option can only support "ne2k_pci", "ne2k_isa", "rtl8139",
"smc91c111" and "lance". Which one of them is e1000. Also I am assuming,
that somewhere I can get e1000 device driver for window server 2003 too..

If there is already a wiki then can you please point me to it.

Also I had a suggestion. Would it make sense to update the wiki page to say,
that if you use NAT it will be slower, and for performance, the bridge model
should be used.
Just to make it explicit. I am ready to make the change, if everyone blesses
it..

Thanks a lot
Regards
Deep


-- 
Thanks
Dp
[The force is feminine in nature]
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] how increase performance of network io in kvm

2008-03-11 Thread Jorge Lucángeli Obes
> Thanks a lot for your help.. man
>
> So, the performance numbers with public bridge, actually increases the
> performance by many folds. Now I can copy the same 1 gb file in 1.30 mins..
> which is awesome.

Cool!

> Now a dumb question (sorry :( ), but how do I use e1000 nic device and
> driver. -net option can only support "ne2k_pci", "ne2k_isa", "rtl8139",
> "smc91c111" and "lance". Which one of them is e1000. Also I am assuming,
> that somewhere I can get e1000 device driver for window server 2003 too..

I don't know if the driver is included in Windows 2K3 but it should be
easy to find if not. I would try using 'e1000' as the device, that's
probably how it was named and it's not yet included in the help text.

> If there is already a wiki then can you please point me to it.
>
> Also I had a suggestion. Would it make sense to update the wiki page to say,
> that if you use NAT it will be slower, and for performance, the bridge model
> should be used.
>  Just to make it explicit. I am ready to make the change, if everyone
> blesses it..

The VMGL/KVM mini-HOWTO mentions the massive drop in performance using
usermode networking, but I think it would be useful to have it in the
main networking page also. I would say go ahead, that's what wikis are
for =).

Jorge

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] Boot script

2008-03-11 Thread Matthias Pfafferodt
Hello,

my server runs XEN with 5 domains at the moment. I will get new hardware this 
week and I think about trying to do the virtualisation using KVM.

Xen has small scripts which

* set up the bridged network at boot
* start all domains at boot time (or restore saved domains)
* save the domains at shutdown

Are there such scripts for KVM? I would like to have an init script which does 
all the things listed above.

Is this even possible with qemu/kvm (save/restore a domain using shell 
commands)?

Thanks

Matthias

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] PCI IO regions must be power of two

2008-03-11 Thread Anthony Liguori
Marcelo Tosatti wrote:
> Anthony,
>
> Both virtio-net and virtio-block currently register PCI IO space regions
> that are not power of two in size.
>
> The decoding process to discover the size of a PCI resource expects it
> to be a power of two. The PCI controller masks the size out of what is
> written into
>
> config_space + 0x10 + (4 * region_num)
>
> The result is that the size is calculated and registered erroneously 
> by the OS:
>
> [EMAIL PROTECTED] ~]# cat /proc/ioports  | grep virtio
>   c200-c203 : virtio-pci
>
> This is a virtio-block device whose BAR0 has length (16+20)-1, not 4. 
>
>   BAR0: I/O at 0xc200 [0xc223].
>
> I suggest forcing the size to be power of two as follows:
>
>   

A quick grep of the source show that virtio seems to be the only device 
that isn't behaving here.  I suggest modifying the virtio.c to always 
use a power of two and then perhaps adding a check in hw/pci.c to 
validate that the registered region is a power of two in size.

Regards,

Anthony Liguori

> Index: kvm-userspace.hotplug2/qemu/hw/pci.c
> ===
> --- kvm-userspace.hotplug2.orig/qemu/hw/pci.c
> +++ kvm-userspace.hotplug2/qemu/hw/pci.c
> @@ -236,6 +236,13 @@ void pci_register_io_region(PCIDevice *p
>
>  if ((unsigned int)region_num >= PCI_NUM_REGIONS)
>  return;
> +
> +/* IO region size must be power of two */
> +if (type == PCI_ADDRESS_SPACE_IO && (size & (size-1))) {
> +size = size << 1;
> +size &= size-1;
> +}
> +
>  r = &pci_dev->io_regions[region_num];
>  r->addr = -1;
>  r->size = size;
>
>   


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] Boot script

2008-03-11 Thread Javier Guerra
On Tue, Mar 11, 2008 at 4:38 PM, Matthias Pfafferodt <[EMAIL PROTECTED]> wrote:
>  * set up the bridged network at boot

trivially easy.  in fact, it's easier to write a script than to do it by hand.

>  * start all domains at boot time (or restore saved domains)

from trivial to moderate, depending on the disk layout.

>  * save the domains at shutdown

moderately tricky.  you'd have to put the kvm control console
somewhere your shutdown script could find them, and send the 'savevm'
commands.


>  Are there such scripts for KVM? I would like to have an init script which 
> does
>  all the things listed above.

i haven't seen any one, i feel it should be done for your specific requirements.

>  Is this even possible with qemu/kvm (save/restore a domain using shell
>  commands)?

totally possible.  restore is just a commandline switch (or automatic
if using qcow images).  savevm is a control command, so you'll have to
redirect the control to a pipe; then the script would simply do an
"echo 'savevm;quit' > kvm-xx.pipe"


-- 
Javier

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] Boot script

2008-03-11 Thread Anthony Liguori
Matthias Pfafferodt wrote:
> Hello,
>
> my server runs XEN with 5 domains at the moment. I will get new hardware this 
> week and I think about trying to do the virtualisation using KVM.
>
> Xen has small scripts which
>
> * set up the bridged network at boot
>   

I just manually configure a bridge through my distro's networking 
scripts.  I've got what I do fully documented at 
http://kvm.qumranet.com/kvmwiki/AnthonyLiguori/Networking

You can also use libvirt to manage KVM in which case, it will 
automagically configure networking for you.

> * start all domains at boot time (or restore saved domains)
>   

I just use a script in /etc/init.d/ that I wrote but libvirt will also 
do this for you.

> * save the domains at shutdown
>   

As in, do a save at shutdown?  That seems pretty scary to me.  I don't 
know what libvirt does on shutdown but I'm sure someone can chime in.

> Are there such scripts for KVM? I would like to have an init script which 
> does 
> all the things listed above.
>
> Is this even possible with qemu/kvm (save/restore a domain using shell 
> commands)?
>   

You have two options.  If you use libvirt, you can issue commands via 
virsh.  If you don't use libvirt, you need to have the monitor sit on a 
unix domain socket or on a TCP socket and you can issue commands to the 
monitor via a tool like socat.

libvirt is by far the simplest choice for managing KVM but it's possible 
to do these things without it.

Regards,

Anthony Liguori

> Thanks
>
> Matthias
>
> -
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
> ___
> kvm-devel mailing list
> kvm-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/kvm-devel
>   


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] loop in copy_user_generic_string

2008-03-11 Thread Zdenek Kabelac
2008/3/9, Zdenek Kabelac <[EMAIL PROTECTED]>:
> 2008/3/7, Zdenek Kabelac <[EMAIL PROTECTED]>:
>
> > 2008/3/5, Zdenek Kabelac <[EMAIL PROTECTED]>:
>  >
>  > > 2008/3/5, Avi Kivity <[EMAIL PROTECTED]>:
>  >  >
>  >  > > Andi Kleen wrote:
>  >  >  >  > Avi Kivity <[EMAIL PROTECTED]> writes:
>  >  >  >  >
>  >  >  >  >> Most likely movs emulation is broken for long counts.  Please 
> post a
>  >  >  >  >> disassembly of copy_user_generic_string to make sure we're 
> looking at
>  >  >  >  >> the same code.
>  >  >  >  >>
>  >  >  >  >
>  >  >  >  > Be careful -- this code is patched at runtime and what you
>  >  >  >  > see in the vmlinux is not necessarily the same that is executed
>  >  >  >  >
>  >  >  >  >
>  >  >  >
>  >  >  >
>  >  >  > If the disassembled instruction isn't marked as an alternative in the
>  >  >  >  source, then it can't be patched, right?
>  >  >  >
>  >
>  >
>  > Hello
>  >
>  >  Any progress on this - It looks like I get this bug quite often when I 
> test
>  >  device-mapper code.
>  >
>
>
>
> Hello
>
>  I've made some more experiments and noticed few more things:
>
>  a) - it is just enough to run parallel loop with cat LVM partition
>  >/dev/null and dmsetup status
>
>  b) when I insert for() loop for zeroing allocated memory in the
>  dm-ioctl copy_params function my loop start once the memory crosses
>  exactly 4KB boundary (visible from register content)
>
>  c) in my trace log I could usually always see this pattern:
>  [  160.634897]  [] preempt_schedule_irq+0x5a/0xa0
>  [  160.634897]  [] retint_kernel+0x26/0x30
>
>  from the look in the arch/x86/kernel/entry64.s I could really see
>  there is some potentiality for internal loop that may call
>  preempt_schedule_irq in upon some check in  exit_intr - but having
>  actually now idea what's this all about...
>
>  I've put there just some extra dump_stack trace in the
>  preempt_schedule_irq - and it's really being printed - but quite
>  slowly actually considering process eats 100% CPU
>
>  So anyone has any idea what might be wrong ?


Hello

I've some more news here - it looks I've found working setup on my C2D.

All I need to do is compile my 64bit kernel with optimization for space.
This will magical start to work - at least in this case.

I'll now probably slowly try to figure out which directory with -Os
compilation makes the difference.

Also I've noticed that standard Debian 2.6.24-4-686 kernel loops in
Qemu, but 486 version doesn't.

So if anyone starts to get idea what could be wrong...

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] how increase performance of network io in kvm

2008-03-11 Thread Dhirendra Pal Singh
On Tue, Mar 11, 2008 at 2:03 PM, Jorge Lucángeli Obes <[EMAIL PROTECTED]>
wrote:

> > Thanks a lot for your help.. man
> >
> > So, the performance numbers with public bridge, actually increases the
> > performance by many folds. Now I can copy the same 1 gb file in 1.30mins..
> > which is awesome.
>
> Cool!
>
> > Now a dumb question (sorry :( ), but how do I use e1000 nic device and
> > driver. -net option can only support "ne2k_pci", "ne2k_isa", "rtl8139",
> > "smc91c111" and "lance". Which one of them is e1000. Also I am assuming,
> > that somewhere I can get e1000 device driver for window server 2003
> too..
>
> I don't know if the driver is included in Windows 2K3 but it should be
> easy to find if not. I would try using 'e1000' as the device, that's
> probably how it was named and it's not yet included in the help text.


I tried e1000 and it says  "qemu: Unsupported NIC: e1000" :( Did I miss
something.. ?

I downloaded the latest code base for qemu, and I see the following lines in
qemu-doc.texi

*
@code{i82551}, @code{i82557b}, @code{i82559er},
@code{ne2k_pci}, @code{ne2k_isa}, @code{pcnet}, @code{rtl8139},
@code{smc91c111}, @code{lance} and @code{mcf_fec}.
*

I don't see any e1000 entry there? Meanwhile I am trying to build latest
version of qemu and see if it gets me anywhere.


>
> > If there is already a wiki then can you please point me to it.
> >
> > Also I had a suggestion. Would it make sense to update the wiki page to
> say,
> > that if you use NAT it will be slower, and for performance, the bridge
> model
> > should be used.
> >  Just to make it explicit. I am ready to make the change, if everyone
> > blesses it..
>
> The VMGL/KVM mini-HOWTO mentions the massive drop in performance using
> usermode networking, but I think it would be useful to have it in the
> main networking page also. I would say go ahead, that's what wikis are
> for =).


Done... :)
Also when I get this e1000 thingi working, I am going to add this to the
wiki too :)

Thanks and Regards
Deep



>
> Jorge
>



-- 
Thanks
Dp
[The force is feminine in nature]
-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] KVM Test result, kernel a16664b.., userspace3017d05.. one new issue

2008-03-11 Thread Yunfeng Zhao
Chris Wedgwood wrote:
> On Mon, Mar 10, 2008 at 05:27:32PM +0800, Yunfeng Zhao wrote:
>
>   
>> One new issue:
>> 1.  booting smp windows guests has 30% chance of hang
>> https://sourceforge.net/tracker/?func=detail&atid=893831&aid=1910923&group_id=180599
>> 
>
>   
>> PlatformWoodcrest
>> CPU 4
>> Memory size 8G'
>> 
>
> Is that a CPU with FlexPriority?
>
>   
Yes, it has FlexPriority.

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] no mouse

2008-03-11 Thread aGaTHoS
CPU: AMD Athlon(tm) 64 X2 Dual Core Processor 4800+
kvm version: 62
kernel: 2.6.23-hardened-r7 (with gentoo standard and hardened patches, it is 
anyway compiled without ssp and pie)
arch: x86_64
guest OS: various, windows XP and various linux livecds
command line:

 1 (windows) # kvm -hda /root/kvm/windows.img -m 192 -localtime -k es -net nic 
-net tap,script=/etc/kvm/br1

 2 (livecd f.e puppy) # kvm -hda /root/kvm/live.img -cdrom 
/home/agathos/data/downloads/puppy-3.01-seamonkey.iso -boot d -name live -m 192 
-localtime -k es -std-vga -net nic -net tap,script=/etc/kvm/br1

with -no-kvm : it crashes after entering command

description of the bug:
I can remember the exact version since the problem occurs, but with the 
last versions of kvm I have no mouse, it appears when starting windows or X in 
linux and when I try to move it, simply deappears. I've also tried with "-usb 
-usbdevice mouse" with the same result.

-- 
Hugo Amorós Salvador <[EMAIL PROTECTED]>

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 5 of 7] Add dynamic device tree manipulation & change uboot loader for PPC bamboo board model

2008-03-11 Thread Jerone Young
# HG changeset patch
# User Jerone Young <[EMAIL PROTECTED]>
# Date 1205296680 18000
# Branch merge
# Node ID 50fddb23a4c19ec6f359a4dd39e98712eb6bcaeb
# Parent  9c15709640cd55bf6f782d6856423363312493bb
Add dynamic device tree manipulation & change uboot loader for PPC bamboo board 
model

This patch adds code to dynamically manipulate the device tree when loaded into 
memory. This allows us to finally have the ability to manipulate the kernel 
command line & initrd from the qemu command line. This will also let us setup 
different settings for the board.

This patch also now uses new uboot loader uboot_loader_l() to load kernel image.

Signed-off-by: Jerone Young <[EMAIL PROTECTED]>

diff --git a/qemu/Makefile.target b/qemu/Makefile.target
--- a/qemu/Makefile.target
+++ b/qemu/Makefile.target
@@ -615,7 +615,7 @@ OBJS+= unin_pci.o ppc_chrp.o
 OBJS+= unin_pci.o ppc_chrp.o
 # PowerPC 4xx boards
 OBJS+= pflash_cfi02.o ppc4xx_devs.o ppc405_uc.o ppc405_boards.o
-OBJS+= ppc440.o ppc440_bamboo.o
+OBJS+= ppc440.o ppc440_bamboo.o ppc_device_tree_support.o
 endif
 ifeq ($(TARGET_BASE_ARCH), mips)
 OBJS+= mips_r4k.o mips_malta.o mips_pica61.o mips_mipssim.o
diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c
--- a/qemu/hw/ppc440_bamboo.c
+++ b/qemu/hw/ppc440_bamboo.c
@@ -8,11 +8,12 @@
  *
  */
 
+#include "config.h"
 #include "ppc440.h"
+#include "qemu-kvm.h"
+#include "ppc_device_tree_support.h"
 
-#define KERNEL_LOAD_ADDR 0x40 /* uboot loader puts kernel at 4MB */
-
-#include "qemu-kvm.h"
+#define BINARY_DEVICE_TREE_FILE "bamboo.dtb"
 
 /* PPC 440 refrence demo board
  *
@@ -26,14 +27,22 @@ void bamboo_init(ram_addr_t ram_size, in
const char *initrd_filename,
const char *cpu_model)
 {
+   char buf[1024]; 
target_phys_addr_t ram_bases[2], ram_sizes[2];
qemu_irq *pic;
CPUState *env;
-   target_ulong ep;
+   target_ulong ep=0;
+   target_ulong la=0;
int is_linux=1; /* Will assume allways is Linux for now */
-   long kernel_size=0;
+   target_long kernel_size=0;
target_ulong initrd_base=0;
-   target_ulong initrd_size=0;
+   target_long initrd_size=0;
+   target_ulong dt_base=0;
+   void *fdt;
+   int ret;
+
+   uint32_t cpu_freq;
+   uint32_t timebase_freq;
 
printf("%s: START\n", __func__);
 
@@ -78,18 +87,23 @@ void bamboo_init(ram_addr_t ram_size, in
 
/* load kernel with uboot loader */
printf("%s: load kernel\n", __func__);
-   kernel_size = load_uboot(kernel_filename, &ep, &is_linux);
+   load_uboot_l(kernel_filename, &ep, &la, &kernel_size, &is_linux);
if (kernel_size < 0) {
fprintf(stderr, "qemu: could not load kernel '%s'\n",
kernel_filename);
exit(1);
}
+   printf("kernel is at guest address: 0x%lx\n", (unsigned long)la);
 
/* load initrd */
if (initrd_filename) {
-   initrd_base = kernel_size + KERNEL_LOAD_ADDR;
+   initrd_base = kernel_size + la;
+   printf("%s: load initrd\n", __func__);
initrd_size = load_image(initrd_filename,
phys_ram_base + initrd_base);
+
+   printf("initrd is at guest address: 0x%lx\n", 
+   (unsigned long) initrd_base);
 
if (initrd_size < 0) {
fprintf(stderr,
@@ -99,17 +113,58 @@ void bamboo_init(ram_addr_t ram_size, in
}
}
 
+#ifdef CONFIG_LIBFDT
+   /* get variable for device tree */
+   cpu_freq = get_proc_dt_prop_cpu_clock_freq();
+   timebase_freq = get_proc_dt_prop_cpu_timebase_freq();
+
+   /* load binary device tree into qemu (not guest memory) */
+   printf("%s: load device tree file\n", __func__);
+   
+   snprintf(buf, sizeof(buf), "%s/%s", bios_dir, 
+   BINARY_DEVICE_TREE_FILE);
+
+   /* set base for device tree that will be in guest memory */ 
+   if (initrd_base)
+   dt_base = initrd_base + initrd_size;
+   else
+   dt_base = kernel_size + la;
+
+   fdt = load_device_tree(buf, (phys_ram_base + dt_base));
+   if (fdt == NULL) {
+   printf("Loading device tree failed!\n");
+   exit(1);
+   }
+
+   printf("device tree address is at guest address: 0x%lx\n", 
+   (unsigned long) dt_base);
+
+   /* manipulate device tree in memory */
+   set_dt_cpu_0_clock_freq_prop(fdt, cpu_freq);
+   set_dt_cpu_0_timebase_prop(fdt, timebase_freq);
+
+   set_dt_initrd_start_prop(fdt, initrd_base);
+   set_dt_initrd_end_prop(fdt, (initrd_base + initrd_size));
+
+   set_dt_bootargs_prop(fdt, kernel_cmdline);
+#endif
+
if (kvm_enabled()) {
-   /* XXX insert TLB entries */
-   env->gpr[1] = (16<<20) - 8;
-   env->gpr[4] = initrd_base;
-  

[kvm-devel] [PATCH 4 of 7] Add PPC 440EP bamboo board device tree source & binary into qemu

2008-03-11 Thread Jerone Young
# HG changeset patch
# User Jerone Young <[EMAIL PROTECTED]>
# Date 1205296680 18000
# Branch merge
# Node ID 9c15709640cd55bf6f782d6856423363312493bb
# Parent  48651677b7d05254d6acf03551bfea05cef8aa47
Add PPC 440EP bamboo board device tree source & binary into qemu

This patch places the bamboo device tree for the PPC 440EP bamboo board into 
the pc-bios directory of the qemu source. This also adds a rule into the 
pc-bios/Makefile to build device tree files.

Signed-off-by: Jerone Young <[EMAIL PROTECTED]>

diff --git a/qemu/pc-bios/Makefile b/qemu/pc-bios/Makefile
--- a/qemu/pc-bios/Makefile
+++ b/qemu/pc-bios/Makefile
@@ -12,6 +12,9 @@ all: $(TARGETS)
 %.o: %.S
$(CC) $(DEFINES) -c -o $@ $<
 
+%.dtb: %.dts 
+   dtc -O dtb -I dts -o $@ $< 
+
 clean:
-   rm -f $(TARGETS) *.o *~
+   rm -f $(TARGETS) *.o *~ *.dtb
 
diff --git a/qemu/pc-bios/bamboo.dts b/qemu/pc-bios/bamboo.dts
new file mode 100644
--- /dev/null
+++ b/qemu/pc-bios/bamboo.dts
@@ -0,0 +1,310 @@
+/*
+ * Device Tree Source for AMCC Bamboo
+ *
+ * Copyright (c) 2006, 2007 IBM Corp.
+ * Josh Boyer <[EMAIL PROTECTED]>
+ *
+ * FIXME: Draft only!
+ *
+ * This file is licensed under the terms of the GNU General Public
+ * License version 2.  This program is licensed "as is" without
+ * any warranty of any kind, whether express or implied.
+ */
+
+/ {
+   #address-cells = <2>;
+   #size-cells = <1>;
+   model = "amcc,bamboo";
+   compatible = "amcc,bamboo";
+   dcr-parent = <&/cpus/[EMAIL PROTECTED]>;
+
+   aliases {
+/* ethernet0 = &EMAC0;  */
+/* ethernet1 = &EMAC1;  *
+   serial0 = &UART0;
+   serial1 = &UART1;   
+/* serial2 = &UART2;*/
+/* serial3 = &UART3;*/
+   };
+
+   cpus {
+   #address-cells = <1>;
+   #size-cells = <0>;
+
+   [EMAIL PROTECTED] {
+   device_type = "cpu";
+   model = "PowerPC,440EP";
+   reg = <0>;
+   clock-frequency = <1fca0550>; /* Filled in by zImage */
+   timebase-frequency = <017d7840>; /* Filled in by zImage 
*/
+   i-cache-line-size = <20>;
+   d-cache-line-size = <20>;
+   i-cache-size = <8000>;
+   d-cache-size = <8000>;
+   dcr-controller;
+   dcr-access-method = "native";
+   };
+   };
+
+   memory {
+   device_type = "memory";
+   reg = <0 0 900>; /* Filled in by zImage */
+   };
+
+   UIC0: interrupt-controller0 {
+   compatible = "ibm,uic-440ep","ibm,uic";
+   interrupt-controller;
+   cell-index = <0>;
+   dcr-reg = <0c0 009>;
+   #address-cells = <0>;
+   #size-cells = <0>;
+   #interrupt-cells = <2>;
+   };
+/*
+   UIC1: interrupt-controller1 {
+   compatible = "ibm,uic-440ep","ibm,uic";
+   interrupt-controller;
+   cell-index = <1>;
+   dcr-reg = <0d0 009>;
+   #address-cells = <0>;
+   #size-cells = <0>;
+   #interrupt-cells = <2>;
+   interrupts = <1e 4 1f 4>; 
+   interrupt-parent = <&UIC0>;
+   };
+*/
+
+   SDR0: sdr {
+   compatible = "ibm,sdr-440ep";
+   dcr-reg = <00e 002>;
+   };
+
+   CPR0: cpr {
+   compatible = "ibm,cpr-440ep";
+   dcr-reg = <00c 002>;
+   };
+
+   plb {
+   compatible = "ibm,plb-440ep", "ibm,plb-440gp", "ibm,plb4";
+   #address-cells = <2>;
+   #size-cells = <1>;
+   ranges;
+   clock-frequency = <07f28154>; /* Filled in by zImage */
+
+   SDRAM0: sdram {
+   compatible = "ibm,sdram-440ep", "ibm,sdram-405gp";
+   dcr-reg = <010 2>;
+   };
+
+   DMA0: dma {
+   compatible = "ibm,dma-440ep", "ibm,dma-440gp";
+   dcr-reg = <100 027>;
+   };
+
+/*
+   MAL0: mcmal {
+   compatible = "ibm,mcmal-440ep", "ibm,mcmal-440gp", 
"ibm,mcmal";
+   dcr-reg = <180 62>;
+   num-tx-chans = <4>;
+   num-rx-chans = <2>;
+   interrupt-parent = <&MAL0>;
+   interrupts = <0 1 2 3 4>;
+   #interrupt-cells = <1>;
+   #address-cells = <0>;
+   #size-cells = <0>;
+   interrupt-map = <0 &UIC0 a 4
+ 1 &UIC0 b 4
+ 2 &UIC1 0 4
+ 3 &UIC1 1 4
+ 4 &UIC1 2 4>;

[kvm-devel] [PATCH 0 of 7] PowerPC kvm-userspace patches

2008-03-11 Thread Jerone Young
This set of patches enables the following:
-Device tree Support
- Add libfdt to kvm-userspace
- Add bamboo device tree to qemu source
- Detection of host Device Tree attributes
- Device tree loading
- Ability to specify initrd on the command line
- Ability to add kernel arguments on the command line
- Ability to load compressed uImages
- Ability to specify memory on the command line

So now when running powerpc code on a 440board. 

Known Issues:
   There is an issue currently where guest kernel is not mounting the initrd.
   Working it now!

   But these changes should go in anyway.

Signed-off-by: Jerone Young <[EMAIL PROTECTED]>

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 6 of 7] Modify PPC bamboo & ppc440 board models

2008-03-11 Thread Jerone Young
# HG changeset patch
# User Jerone Young <[EMAIL PROTECTED]>
# Date 1205296680 18000
# Branch merge
# Node ID 3a891d8fada96166089b5796f3241087d4aae50f
# Parent  50fddb23a4c19ec6f359a4dd39e98712eb6bcaeb
Modify PPC bamboo & ppc440 board models

This patch renames pp440_init to ppc440ep_init, as ppc440 is the name of the 
core and ppc440ep is the name of the SOC. When we init we are initializing the 
SOC.

Also in this patch we now call cpu_ppc_init for bamboo with string 440 .. as 
440 is the core.

Signed-off-by: Jerone Young <[EMAIL PROTECTED]>

diff --git a/qemu/hw/ppc440.c b/qemu/hw/ppc440.c
--- a/qemu/hw/ppc440.c
+++ b/qemu/hw/ppc440.c
@@ -10,7 +10,7 @@
 
 #include "ppc440.h"
 
-void ppc440_init(CPUState *env,
+void ppc440ep_init(CPUState *env,
target_phys_addr_t ram_bases[2],
target_phys_addr_t ram_sizes[2],
qemu_irq **picp,
diff --git a/qemu/hw/ppc440.h b/qemu/hw/ppc440.h
--- a/qemu/hw/ppc440.h
+++ b/qemu/hw/ppc440.h
@@ -20,7 +20,7 @@
 #include "exec-all.h"
 #include "boards.h"
 
-void ppc440_init(CPUState *env,
+void ppc440ep_init(CPUState *env,
target_phys_addr_t ram_bases[2],
target_phys_addr_t ram_sizes[2],
qemu_irq **picp,
diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c
--- a/qemu/hw/ppc440_bamboo.c
+++ b/qemu/hw/ppc440_bamboo.c
@@ -68,8 +68,7 @@ void bamboo_init(ram_addr_t ram_size, in
printf("Ram size of domain is %d bytes\n", (int)ram_size);
 
/* Setup CPU */
-   /* XXX We cheat for now and use 405 */
-   env = cpu_ppc_init("405");
+   env = cpu_ppc_init("440");
if (!env) {
fprintf(stderr, "Unable to initilize CPU!\n");
exit(1);
@@ -77,7 +76,7 @@ void bamboo_init(ram_addr_t ram_size, in
 
/* call init */
printf("Calling function ppc440_init\n");
-   ppc440_init(env, ram_bases, ram_sizes, &pic,1);
+   ppc440ep_init(env, ram_bases, ram_sizes, &pic,1);
printf("Done calling ppc440_init\n");
 
/* Register mem */

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 2 of 7] Add libfdt support to qemu

2008-03-11 Thread Jerone Young
# HG changeset patch
# User Jerone Young <[EMAIL PROTECTED]>
# Date 1205296680 18000
# Branch merge
# Node ID 36d2646a3c3d42021425febf3d14f0500ebbaace
# Parent  cb3ca3805e7735fffcf42032b917cc761b145fb3
Add libfdt support to qemu

This patch adds needed configuration options to compile in libfdt support
into qemu.

Signed-off-by: Jerone Young <[EMAIL PROTECTED]>

diff --git a/qemu/Makefile.target b/qemu/Makefile.target
--- a/qemu/Makefile.target
+++ b/qemu/Makefile.target
@@ -555,6 +555,11 @@ ifdef CONFIG_VNC_TLS
 ifdef CONFIG_VNC_TLS
 CPPFLAGS += $(CONFIG_VNC_TLS_CFLAGS)
 LIBS += $(CONFIG_VNC_TLS_LIBS)
+endif
+
+ifdef CONFIG_LIBFDT
+LIBS += -lfdt
+DEPLIBS += libfdt.a
 endif
 
 # SCSI layer
diff --git a/qemu/configure b/qemu/configure
--- a/qemu/configure
+++ b/qemu/configure
@@ -112,6 +112,7 @@ uname_release=""
 uname_release=""
 curses="yes"
 cpu_emulation="yes"
+device_tree_support="no"
 
 # OS specific
 targetos=`uname -s`
@@ -345,6 +346,8 @@ for opt do
   ;;
   --disable-cpu-emulation) cpu_emulation="no"
   ;;
+  --enable-libfdt) device_tree_support="yes"
+  ;;
   *) echo "ERROR: unknown option $opt"; exit 1
   ;;
   esac
@@ -449,6 +452,7 @@ echo "  --enable-uname-release=R Return 
 echo "  --enable-uname-release=R Return R for uname -r in usermode emulation"
 echo "  --sparc_cpu=VBuild qemu for Sparc architecture v7, v8, 
v8plus, v8plusa, v9"
 echo "  --disable-cpu-emulation  disables use of qemu cpu emulation code"
+echo "  --enable-libfdt enable libfdt support for device tree support"
 echo ""
 echo "NOTE: The object files are built at the place where configure is 
launched"
 exit 1
@@ -1186,6 +1190,10 @@ elif test "$target_cpu" = "ppcemb" ; the
   echo "#define TARGET_ARCH \"ppcemb\"" >> $config_h
   echo "#define TARGET_PPC 1" >> $config_h
   echo "#define TARGET_PPCEMB 1" >> $config_h
+  if test "$device_tree_support" = "yes" ; then
+  echo "#define CONFIG_LIBFDT 1" >> $config_h
+  echo "CONFIG_LIBFDT=1" >> $config_mak
+  fi
   configure_kvm
 elif test "$target_cpu" = "ppc64" ; then
   echo "TARGET_ARCH=ppc64" >> $config_mak

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] [PATCH 3 of 7] Create new load_uboot() & gunzip support to uboot loader in Qemu

2008-03-11 Thread Jerone Young
# HG changeset patch
# User Jerone Young <[EMAIL PROTECTED]>
# Date 1205296680 18000
# Branch merge
# Node ID 48651677b7d05254d6acf03551bfea05cef8aa47
# Parent  36d2646a3c3d42021425febf3d14f0500ebbaace
Create new load_uboot() & gunzip support to uboot loader in Qemu

This patch adds the ability for the load address to be caputred when loading a 
uImage or cuImage. It also adds a better return code as the size can be an 
usigned long. This is done by creating a new function prototype and calling it 
load_uboot_l . To keep compatibility with code already using the old load_uboot 
a wrapper function has been created so current callers will not break them.

Also added is gunzip support to allow for loading of uimages with a compressed 
kenrel imagexs.

Signed-off-by: Jerone Young <[EMAIL PROTECTED]>

diff --git a/qemu/loader.c b/qemu/loader.c
--- a/qemu/loader.c
+++ b/qemu/loader.c
@@ -26,6 +26,8 @@
 #include "sysemu.h"
 #include "uboot_image.h"
 
+#include 
+
 /* return the size or -1 if error */
 int get_image_size(const char *filename)
 {
@@ -263,14 +265,103 @@ static void bswap_uboot_header(uboot_ima
 }
 
 /* Load a U-Boot image.  */
-int load_uboot(const char *filename, target_ulong *ep, int *is_linux)
-{
-
+
+/* gunzip functionality is derived from gunzip function 
+ * in uboot source code 
+ */
+
+#defineZALLOC_ALIGNMENT16
+
+static void *zalloc(void *x, unsigned items, unsigned size)
+{
+   void *p;
+
+   size *= items;
+   size = (size + ZALLOC_ALIGNMENT - 1) & ~(ZALLOC_ALIGNMENT - 1);
+
+   p = malloc (size);
+
+   return (p);
+}
+
+static void zfree(void *x, void *addr, unsigned nb)
+{
+   free (addr);
+}
+
+
+#define HEAD_CRC   2
+#define EXTRA_FIELD4
+#define ORIG_NAME  8
+#define COMMENT0x10
+#define RESERVED   0xe0
+
+#define DEFLATED   8
+
+static int gunzip(void *dst, int dstlen, unsigned char *src, unsigned long 
*lenp)
+{
+   z_stream s;
+   int r, i, flags;
+
+   /* skip header */
+   i = 10;
+   flags = src[3];
+   if (src[2] != DEFLATED || (flags & RESERVED) != 0) {
+   puts ("Error: Bad gzipped data\n");
+   return -1;
+   }
+   if ((flags & EXTRA_FIELD) != 0)
+   i = 12 + src[10] + (src[11] << 8);
+   if ((flags & ORIG_NAME) != 0)
+   while (src[i++] != 0)
+   ;
+   if ((flags & COMMENT) != 0)
+   while (src[i++] != 0)
+   ;
+   if ((flags & HEAD_CRC) != 0)
+   i += 2;
+   if (i >= *lenp) {
+   puts ("Error: gunzip out of data in header\n");
+   return -1;
+   }
+
+   s.zalloc = zalloc;
+   s.zfree = zfree;
+
+   r = inflateInit2(&s, -MAX_WBITS);
+   if (r != Z_OK) {
+   printf ("Error: inflateInit2() returned %d\n", r);
+   return (-1);
+   }
+   s.next_in = src + i;
+   s.avail_in = *lenp - i;
+   s.next_out = dst;
+   s.avail_out = dstlen;
+   r = inflate(&s, Z_FINISH);
+   if (r != Z_OK && r != Z_STREAM_END) {
+   printf ("Error: inflate() returned %d\n", r);
+   return -1;
+   }
+   *lenp = s.next_out - (unsigned char *) dst;
+   inflateEnd(&s);
+
+   return 0;
+}
+
+
+#define MAX_KERNEL_SIZE 8*1024*1024  //8MB
+int load_uboot_l(const char *filename, target_ulong *ep,
+  target_ulong *la, 
+  target_ulong *loaded_image_size,
+  int *is_linux)
+{
 int fd;
 int size;
+int ret;
 uboot_image_header_t h;
 uboot_image_header_t *hdr = &h;
 uint8_t *data = NULL;
+uint8_t *uncompressed_data = NULL;
 
 fd = open(filename, O_RDONLY | O_BINARY);
 if (fd < 0)
@@ -291,13 +382,14 @@ int load_uboot(const char *filename, tar
 goto fail;
 }
 
-/* TODO: Implement compressed images.  */
-if (hdr->ih_comp != IH_COMP_NONE) {
-fprintf(stderr, "Unable to load compressed u-boot images\n");
+/* TODO bzip2 support */
+if (hdr->ih_comp == IH_COMP_BZIP2) {
+fprintf(stderr, "Unable to load bzip2 compressed u-boot images\n");
 goto fail;
 }
 
 /* TODO: Check CPU type.  */
+
 if (is_linux) {
 if (hdr->ih_type == IH_TYPE_KERNEL && hdr->ih_os == IH_OS_LINUX)
 *is_linux = 1;
@@ -306,6 +398,8 @@ int load_uboot(const char *filename, tar
 }
 
 *ep = hdr->ih_ep;
+*la = hdr->ih_load;
+
 data = qemu_malloc(hdr->ih_size);
 if (!data)
 goto fail;
@@ -315,9 +409,29 @@ int load_uboot(const char *filename, tar
 goto fail;
 }
 
-cpu_physical_memory_write_rom(hdr->ih_load, data, hdr->ih_size);
-
-return hdr->ih_size;
+*loaded_image_size = hdr->ih_size;
+
+if (hdr->ih_comp == IH_COMP_GZIP) {
+   uncompressed_data = qemu_malloc(MAX_KERNEL_SIZE);
+   ret = gunzip(uncompressed_data, MAX_KERNEL_SIZE,
+(unsigned char *

[kvm-devel] [PATCH 7 of 7] Add ability to specify ram on command line for bamboo board model

2008-03-11 Thread Jerone Young
# HG changeset patch
# User Jerone Young <[EMAIL PROTECTED]>
# Date 1205296680 18000
# Branch merge
# Node ID 8b1dd3609551efefbd6633ac6fe4caa3a6cbe5e9
# Parent  3a891d8fada96166089b5796f3241087d4aae50f
Add ability to specify ram on command line for bamboo board model

This patch adds the ability to now specify ram sizes on the command line.
Due to the nature of the code there are restictions on exactly how
much ram and the multiple that the size must match.

Signed-off-by: Jerone Young <[EMAIL PROTECTED]>

diff --git a/qemu/hw/ppc440_bamboo.c b/qemu/hw/ppc440_bamboo.c
--- a/qemu/hw/ppc440_bamboo.c
+++ b/qemu/hw/ppc440_bamboo.c
@@ -40,32 +40,71 @@ void bamboo_init(ram_addr_t ram_size, in
target_ulong dt_base=0;
void *fdt;
int ret;
+   int holdr;
+   unsigned long ram_size1; /* Value will be in bytes */
+   unsigned long ram_size2; /* Value will be in bytes */
+
 
uint32_t cpu_freq;
uint32_t timebase_freq;
 
printf("%s: START\n", __func__);
 
-   /* Setup Memory */
-   if (ram_size) {
-   printf("Ram size specified on command line is %i bytes\n",
-   (int)ram_size);
-   printf("WARNING: RAM is hard coded to 144MB\n");
-   }
-   else {
-   printf("Using defualt ram size of %iMB\n",
-   ((int)ram_size/1024)/1024);
-   }
-
-   /* Each bank can only have memory in configurations of
-*   16MB, 32MB, 64MB, 128MB, or 256MB
-*/
-   ram_bases[0] = 0x0;
-   ram_sizes[0] = 0x0800;
-   ram_bases[1] = 0x0;
-   ram_sizes[1] = 0x0100;
-
-   printf("Ram size of domain is %d bytes\n", (int)ram_size);
+   /* Setup Memory */
+   printf("Ram size is set to: %i MB\n",
+   ((int)ram_size/1024)/1024); 
+ 
+   /* Check that total ram is at least 8 MB 
+* but less than 512 MB 
+* and is a multiple of 4
+*/
+ 
+   if (ram_size < (8 * 1024 * 1024)) {
+   printf("Ram size specified on cmd line must at least be 8 
MB\n");
+   exit(1);
+   }
+ 
+   if (ram_size > (512 * 1024 * 1024)) {
+   printf("Ram size specified on cmd line is greater than 512 
MB\n");
+   exit(1);
+   }
+ 
+   if int)ram_size/1024)/1024) % 4) {
+   printf("Ram size specified on cmd line must be multiple of 
4\n");
+   exit(1);
+   }
+ 
+   /* split ram into two slots */
+   holdr = (ram_size/(1024*1024))/4;   
+ 
+   /* ram_size2 has to at least have 4MB in it*/
+   ram_size2 = 4 * 1024 * 1024; /* Add 4MB */
+   holdr = holdr - 1;
+ 
+   
+   if ((4 * holdr) <= 256) {
+   /* if what remains is 256MB or less put in first slot */
+   ram_size1 = (4 * holdr) * (1024 * 1024);
+   }
+   else {
+   /* place first 256MB or less in first slot */
+   ram_size1 = 256 * 1024 * 1024;
+   holdr = holdr - (256/4);
+   
+   /* place remainder in slot 2 */
+   ram_size2 += (4 * holdr) * (1024 * 1024);
+   }
+ 
+   /* Each bank can only have memory in configurations of
+*   4MB, 8MB, 16MB, 32MB, 64MB, 128MB, or 256MB
+*   why? see sdram_bcr()
+*   
+*   Max of 512MB
+*/
+   ram_bases[0] = 0x0;
+   ram_sizes[0] = ram_size1;
+   ram_bases[1] = 0x0;
+   ram_sizes[1] = ram_size2;   
 
/* Setup CPU */
env = cpu_ppc_init("440");

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


[kvm-devel] Sound in Vista

2008-03-11 Thread Stuart Jansen
Before I give up completely, I'd like to ask: Does anyone know any
secrets for getting sound to work in Vista that they haven't told
Google?

BTW, I'm amazed by how quickly KVM has improved over the last few
months. Astoundingly great work.


-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel


Re: [kvm-devel] [PATCH] Move kvm_get_pit to libkvm.c common code

2008-03-11 Thread Yang, Sheng
On Wednesday 12 March 2008 04:17:11 Jerone Young wrote:
> # HG changeset patch
> # User Jerone Young <[EMAIL PROTECTED]>
> # Date 1205266548 18000
> # Branch merge
> # Node ID b136c0450c0f7c6ff2262437b1beb9896b1585e3
> # Parent  c14fbbaee36241aa0fab0d6391e47cf9f4ac8012
> Move kvm_get_pit to libkvm.c common code
>
> This fixes compilation issues for PowerPC and other non x86 archs that do
> not have in kernel pit. The pit code is added into the kvm_context in
> kvm-common.h &the error causing the issue is coming from a definition in
> qemu. This seems to be the proper fix as there is also a common function:
> kvm_irqchip_in_kernel
> for in kernel irq that handles this the same way.

OK to me. Sorry for inconvenient...

-- 
Thanks
Yang, Sheng

> Signed-off-by: Jerone Young <[EMAIL PROTECTED]>
> diff --git a/libkvm/libkvm-x86.c b/libkvm/libkvm-x86.c
> --- a/libkvm/libkvm-x86.c
> +++ b/libkvm/libkvm-x86.c
> @@ -660,12 +660,3 @@ int kvm_disable_tpr_access_reporting(kvm
>  }
>
>  #endif
> -
> -int kvm_pit_in_kernel(kvm_context_t kvm)
> -{
> -#ifdef KVM_CAP_PIT
> - return kvm->pit_in_kernel;
> -#else
> - return 0;
> -#endif
> -}
> diff --git a/libkvm/libkvm.c b/libkvm/libkvm.c
> --- a/libkvm/libkvm.c
> +++ b/libkvm/libkvm.c
> @@ -962,3 +962,8 @@ int kvm_irqchip_in_kernel(kvm_context_t
>  {
>  return kvm->irqchip_in_kernel;
>  }
> +
> +int kvm_pit_in_kernel(kvm_context_t kvm)
> +{
> + return kvm->pit_in_kernel;
> +}
> diff --git a/libkvm/libkvm.h b/libkvm/libkvm.h
> --- a/libkvm/libkvm.h
> +++ b/libkvm/libkvm.h
> @@ -530,6 +530,13 @@ int kvm_set_lapic(kvm_context_t kvm, int
>
>  #endif
>
> +/*!
> + * \brief Query wheather in kernel pit is used
> + *
> + *  \param kvm Pointer to the current kvm_context
> + */
> +int kvm_pit_in_kernel(kvm_context_t kvm);
> +
>  #ifdef KVM_CAP_PIT
>
>  /*!
>
> -
> This SF.net email is sponsored by: Microsoft
> Defy all challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
> ___
> kvm-devel mailing list
> kvm-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/kvm-devel

-
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse012070mrt/direct/01/
___
kvm-devel mailing list
kvm-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/kvm-devel