Re: [Xen-devel] [PATCH v9 01/17] VT-d Posted-intterrupt (PI) design

2015-11-10 Thread Dario Faggioli
On Tue, 2015-11-03 at 16:43 +0800, Feng Wu wrote:

> diff --git a/docs/misc/vtd-pi.txt b/docs/misc/vtd-pi.txt
> new file mode 100644
> index 000..f9b4637
> --- /dev/null
> +++ b/docs/misc/vtd-pi.txt

> +With VT-d Posted-interrupt we can get the following advantages:
> +- Direct delivery of external interrupts to running vCPUs without
> VMM
> +intervention
> +- Decrease the interrupt migration complexity. On vCPU migration,
> software
> +can atomically co-migrate all interrupts targeting the migrating
> vCPU. For
> +virtual machines with assigned devices, migrating a vCPU across
> pCPUs
> +either incurs the overhead of forwarding interrupts in software
> (e.g. via VMM
> +generated IPIs), or complexity to independently migrate each
> interrupt targeting
> +the vCPU to the new pCPU. However, after enabling VT-d PI, the
> destination vCPU
> +of an external interrupt from assigned devices is stored in the IRTE
> (i.e.
> +Posted-interrupt Descriptor Address), when vCPU is migrated to
> another pCPU,
> +we will set this new pCPU in the 'NDST' filed of Posted-interrupt

   ^field

> +More information about APICv and CPU-side Posted-interrupt, please
> refer
> +to Chapter 29, and Section 29.6 in the Intel SDM:
> +http://www.intel.com/content/dam/www/public/us/en/documents/manuals/
> 64-ia-32-architectures-software-developer-manual-325462.pdf
> +
ISTR Andrew said something about chapter names and numbers, and about
what to link in these cases, during v8 review.

> +- Update posted-interrupt descriptor during vCPU scheduling
> +
> +The basic idea here is:
> +1. When vCPU is running
> +- Set 'NV' to 'posted_intr_vector'.
> +- Clear 'SN' to accept posted-interrupts.
> +- Set 'NDST' to the pCPU on which the vCPU will be running.
> +2. When vCPU is blocked
> +- Set 'NV' to ' pi_wakeup_vector ', so we can wake up the
> +  related vCPU when posted-interrupt happens for it.
> +  Please refer to the above section about the new global
> vector.
> +- Clear 'SN' to accept posted-interrupts
> +3. When vCPU is preempted or sleeping
> +- Set 'SN' to suppress non-urgent interrupts
> +  (Currently, we only support non-urgent interrupts)
> + When vCPU is preempted or sleep, it doesn't need to accept
> + posted-interrupt notification event since we don't change
> the behavior
> + of scheduler when the interrupt occurs, we still need wait
> for the next
> + scheduling of the vCPU. When external interrupts from
> assigned devices occur,
> + the interrupts are recorded in PIR, and will be synced to
> IRR before VM-Entry.
> +- Set 'NV' to 'posted_intr_vector'.
> +
> +- How to wakeup blocked vCPU when an interrupt is posted for it
> (wakeup notification handler).
> +
>
> [...]
>
> +Here are what we do for the blocked vCPU:
> +1. Define a per-cpu list 'pi_blocked_vcpu', which stored the blocked
> +vCPU on the pCPU.
> +2. When the vCPU is going to block, insert the vCPU
> +to the per-cpu list belonging to the pCPU it was running.
> +3. When the vCPU is unblocked, remove the vCPU from the related pCPU
> list.
> +
> +In the handler of 'pi_wakeup_vector', we do:
> +1. Get the physical CPU.
> +2. Iterate the list 'pi_blocked_vcpu' of the current pCPU, if 'ON'
> is set,
> +we unblock the associated vCPU.
> +
This is indeed more general, and the fact that it does no longer
mentions RUNSTATEs, makes it more adherent to the actual implementation
(and hence more useful), so thanks for doing this.

Personally, I'd add a quick comment about how this, despite being
related to blocking and unblocking, happens actually inside VMX
handlers, i.e., (quickly) what is the relationship within these sets of
events (blocking/unblocking VMENTER/EXIT) and why it is ok to do things
like they are done.

I'm not too fussed about this, though. So, if others don't think
something like this is necessary, I'm fine with what you have here.

Regards,
Dario
-- 
<> (Raistlin Majere)
-
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R Ltd., Cambridge (UK)



signature.asc
Description: This is a digitally signed message part
___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH v2 4/8] util: add virDiskNameParse to handle disk and partition idx

2015-11-10 Thread Joao Martins
Introduce a new helper function "virDiskNameParse" which extends
virDiskNameToIndex but handling both disk index and partition index.
Also rework virDiskNameToIndex to be based on virDiskNameParse.
A test is also added for this function testing both valid and
invalid disk names.

Signed-off-by: Joao Martins 
---
 src/libvirt_private.syms |  1 +
 src/util/virutil.c   | 41 +++
 src/util/virutil.h   |  1 +
 tests/utiltest.c | 56 
 4 files changed, 95 insertions(+), 4 deletions(-)

diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index a835f18..6913d7c 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -149,6 +149,7 @@ virDomainCapsNew;
 # conf/domain_conf.h
 virBlkioDeviceArrayClear;
 virDiskNameToBusDeviceIndex;
+virDiskNameParse;
 virDiskNameToIndex;
 virDomainActualNetDefFree;
 virDomainBlockedReasonTypeFromString;
diff --git a/src/util/virutil.c b/src/util/virutil.c
index cddc78a..76591be 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -537,14 +537,17 @@ const char *virEnumToString(const char *const*types,
 }
 
 /* Translates a device name of the form (regex) /^[fhv]d[a-z]+[0-9]*$/
- * into the corresponding index (e.g. sda => 0, hdz => 25, vdaa => 26)
- * Note that any trailing string of digits is simply ignored.
+ * into the corresponding index and partition number
+ * (e.g. sda0 => (0,0), hdz2 => (25,2), vdaa12 => (26,12))
  * @param name The name of the device
- * @return name's index, or -1 on failure
+ * @param disk The disk index to be returned
+ * @param partition The partition index to be returned
+ * @return 0 on success, or -1 on failure
  */
-int virDiskNameToIndex(const char *name)
+int virDiskNameParse(const char *name, int *disk, int *partition)
 {
 const char *ptr = NULL;
+char *rem;
 int idx = 0;
 static char const* const drive_prefix[] = {"fd", "hd", "vd", "sd", "xvd", 
"ubd"};
 size_t i;
@@ -573,6 +576,36 @@ int virDiskNameToIndex(const char *name)
 if (ptr[n_digits] != '\0')
 return -1;
 
+*disk = idx;
+
+/* Convert trailing digits into our partition index */
+if (partition) {
+*partition = 0;
+
+/* Shouldn't start by zero */
+if (n_digits > 1 && *ptr == '0')
+return -1;
+
+if (n_digits && virStrToLong_i(ptr, , 10, partition) < 0)
+return -1;
+}
+
+return 0;
+}
+
+/* Translates a device name of the form (regex) /^[fhv]d[a-z]+[0-9]*$/
+ * into the corresponding index (e.g. sda => 0, hdz => 25, vdaa => 26)
+ * Note that any trailing string of digits is simply ignored.
+ * @param name The name of the device
+ * @return name's index, or -1 on failure
+ */
+int virDiskNameToIndex(const char *name)
+{
+int idx;
+
+if (virDiskNameParse(name, , NULL))
+idx = -1;
+
 return idx;
 }
 
diff --git a/src/util/virutil.h b/src/util/virutil.h
index 53025f7..02387e0 100644
--- a/src/util/virutil.h
+++ b/src/util/virutil.h
@@ -67,6 +67,7 @@ int virDoubleToStr(char **strp, double number)
 char *virFormatIntDecimal(char *buf, size_t buflen, int val)
 ATTRIBUTE_NONNULL(1) ATTRIBUTE_RETURN_CHECK;
 
+int virDiskNameParse(const char *name, int *disk, int *partition);
 int virDiskNameToIndex(const char* str);
 char *virIndexToDiskName(int idx, const char *prefix);
 
diff --git a/tests/utiltest.c b/tests/utiltest.c
index 98c689d..a8f9060 100644
--- a/tests/utiltest.c
+++ b/tests/utiltest.c
@@ -23,6 +23,23 @@ static const char* diskNames[] = {
 "sdia", "sdib", "sdic", "sdid", "sdie", "sdif", "sdig", "sdih", "sdii", 
"sdij", "sdik", "sdil", "sdim", "sdin", "sdio", "sdip", "sdiq", "sdir", "sdis", 
"sdit", "sdiu", "sdiv", "sdiw", "sdix", "sdiy", "sdiz"
 };
 
+struct testDiskName
+{
+const char *name;
+int idx;
+int partition;
+};
+
+static struct testDiskName diskNamesPart[] = {
+{"sda0",  0,   0},
+{"sdb10", 1,  10},
+{"sdc2147483647", 2,  2147483647},
+};
+
+static const char* diskNamesInvalid[] = {
+"sda00", "sda01", "sdb-1"
+};
+
 static int
 testIndexToDiskName(const void *data ATTRIBUTE_UNUSED)
 {
@@ -79,6 +96,44 @@ testDiskNameToIndex(const void *data ATTRIBUTE_UNUSED)
 
 
 
+static int
+testDiskNameParse(const void *data ATTRIBUTE_UNUSED)
+{
+size_t i;
+int idx;
+int partition;
+struct testDiskName *disk = NULL;
+
+for (i = 0; i < ARRAY_CARDINALITY(diskNamesPart); ++i) {
+disk = [i];
+if (virDiskNameParse(disk->name, , ))
+return -1;
+
+if (disk->idx != idx) {
+VIR_TEST_DEBUG("\nExpect [%d]\n", disk->idx);
+VIR_TEST_DEBUG("Actual [%d]\n", idx);
+return -1;
+}
+
+if (disk->partition != partition) {
+VIR_TEST_DEBUG("\nExpect [%d]\n", disk->partition);
+VIR_TEST_DEBUG("Actual [%d]\n", partition);
+return -1;

Re: [Xen-devel] [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64

2015-11-10 Thread John Stultz
On Tue, Nov 10, 2015 at 7:31 AM, Thomas Gleixner  wrote:
> On Tue, 10 Nov 2015, John Stultz wrote:
>> On Tue, Nov 10, 2015 at 7:10 AM, Stefano Stabellini
>>  wrote:
>> > On Tue, 10 Nov 2015, Arnd Bergmann wrote:
>> >> On Tuesday 10 November 2015 11:57:49 Stefano Stabellini wrote:
>> >> > __current_kernel_time64 returns a struct timespec64, without taking the
>> >> > xtime lock. Mirrors __current_kernel_time/current_kernel_time.
>> >> >
>> >>
>> >> Actually it doesn't mirror __current_kernel_time/current_kernel_time
>> >>
>> >> > diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
>> >> > index ec89d84..b5802bf 100644
>> >> > --- a/include/linux/timekeeping.h
>> >> > +++ b/include/linux/timekeeping.h
>> >> > @@ -19,7 +19,8 @@ extern int do_sys_settimeofday(const struct timespec 
>> >> > *tv,
>> >> >   */
>> >> >  unsigned long get_seconds(void);
>> >> >  struct timespec64 current_kernel_time64(void);
>> >> > -/* does not take xtime_lock */
>> >> > +/* do not take xtime_lock */
>> >> > +struct timespec64 __current_kernel_time64(void);
>> >> >  struct timespec __current_kernel_time(void);
>> >>
>> >> Please change __current_kernel_time into a static inline function
>> >> while you are introducing the new one, to match the patch description ;-)
>> >
>> > The implementation is:
>> >
>> > struct timekeeper *tk = _core.timekeeper;
>> >
>> > return timespec64_to_timespec(tk_xtime(tk));
>> >
>> > which cannot be easily made into a static inline, unless we start
>> > exporting tk_core.
>>
>> So the timekeeper is passed to the notifier. So you probably want something 
>> like
>>
>> struct timespec64 __current_kernel_time64(struct timekeeper *tk)
>> {
>>  return timespec64_to_timespec(tk_xtime(tk));
>> }
>>
>> Then you can cast the priv pointer in the notifier to a timekeeper and
>> use it that way?
>
> Err no. Look at commit 8758a240e2d74c5932ab51a73377e6507b7fd441
>
> i.e. Add the new 64bit function and make the existing one a static
> inline which does the timespec64 to timespec conversion.

So yea. The style there is what should be done.

I'm sort of objecting to a different issue, where the
__current_kernel_time() implementation probably shouldn't be grabbing
the tk_core.timekeeper directly, and instead should take a passed
pointer to a timekeeper. The vdso/pv_clock usage should have a
timekeeper passed to them that they could use.

There's one useage in kdb thats maybe problematic, so maybe this will
need a deeper cleanup.

thanks
-john

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v2] tools/ocaml/xb: Correct calculations of data/space the ring

2015-11-10 Thread Wei Liu
On Tue, Nov 10, 2015 at 10:46:44AM +, Andrew Cooper wrote:
> ml_interface_{read,write}() would miscalculate the quantity of
> data/space in the ring if it crossed the ring boundary, and incorrectly
> return a short read/write.
> 
> This causes a protocol stall, as either side of the ring ends up waiting
> for what they believe to be the other side needing to take the next
> action.
> 
> Correct the calculations to cope with crossing the ring boundary.
> 
> In addition, correct the error detection.  It is a hard error if the
> producer index gets more than a ring size ahead of the consumer, or if
> the consumer ever overtakes the producer.
> 
> Signed-off-by: Andrew Cooper 

I think I will port this patch to cxenstored at some point. As far as I
can tell cxenstored's data / space calculation is bogus in the same way.

Wei.

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH v2 3/8] libxl: implement virDomainInterfaceStats

2015-11-10 Thread Joao Martins
Introduce support for domainInterfaceStats API call for querying
network interface statistics. Consequently it also enables the
use of `virsh domifstat  ` command.

After succesful guest creation we fill the network
interfaces names based on domain, device id and append suffix
if it's emulated in the following form: vif.[-emu]. Because
we need the devid from domain config (which is filled by libxl on domain
create)  we cannot do generate the names in console callback. We also
skip this part in case the name of the interface is manually inserted
by adminstrator.

For getting the interface statistics we resort to virNetInterfaceStats
and let libvirt handle the platform specific nits. Note that the latter
is not yet supported in FreeBSD.

Signed-off-by: Joao Martins 
---
Changes since v1:
 - Fill .ifname after domain start with generated
 name from libxl  based on domain id and devid returned by libxl.
 After that path validation don interfaceStats is enterily based
 on ifname pretty much like the other drivers.
 - Modify commit message reflecting the changes mentioned in
 the previous item.
 - Bump version to 1.2.22
---
 src/libxl/libxl_domain.c | 15 +++
 src/libxl/libxl_driver.c | 48 
 2 files changed, 63 insertions(+)

diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 40dcea1..4fbb3fc 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -901,6 +901,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, 
virDomainObjPtr vm,
 virDomainDefPtr def = NULL;
 virObjectEventPtr event = NULL;
 libxlSavefileHeader hdr;
+ssize_t i;
 int ret = -1;
 uint32_t domid = 0;
 char *dom_xml = NULL;
@@ -1023,6 +1024,20 @@ libxlDomainStart(libxlDriverPrivatePtr driver, 
virDomainObjPtr vm,
  */
 vm->def->id = domid;
 
+for (i = 0; i < vm->def->nnets; i++) {
+virDomainNetDefPtr net = vm->def->nets[i];
+libxl_device_nic *x_nic = _config.nics[i];
+const char *suffix =
+x_nic->nictype != LIBXL_NIC_TYPE_VIF ? "-emu" : "";
+
+if (net->ifname)
+continue;
+
+if (virAsprintf(>ifname, "vif%d.%d%s",
+domid, x_nic->devid, suffix) < 0)
+continue;
+}
+
 /* Always enable domain death events */
 if (libxl_evenable_domain_death(cfg->ctx, vm->def->id, 0, >deathW))
 goto cleanup_dom;
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index f4fc7bc..9a5a74c 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -58,6 +58,7 @@
 #include "virhostdev.h"
 #include "network/bridge_driver.h"
 #include "locking/domain_lock.h"
+#include "virstats.h"
 
 #define VIR_FROM_THIS VIR_FROM_LIBXL
 
@@ -4643,6 +4644,52 @@ libxlDomainIsUpdated(virDomainPtr dom)
 }
 
 static int
+libxlDomainInterfaceStats(virDomainPtr dom,
+  const char *path,
+  virDomainInterfaceStatsPtr stats)
+{
+libxlDriverPrivatePtr driver = dom->conn->privateData;
+virDomainObjPtr vm;
+ssize_t i;
+int ret = -1;
+
+if (!(vm = libxlDomObjFromDomain(dom)))
+goto cleanup;
+
+if (virDomainInterfaceStatsEnsureACL(dom->conn, vm->def) < 0)
+goto cleanup;
+
+if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0)
+goto cleanup;
+
+if (!virDomainObjIsActive(vm)) {
+virReportError(VIR_ERR_OPERATION_INVALID,
+   "%s", _("domain is not running"));
+goto endjob;
+}
+
+/* Check the path is one of the domain's network interfaces. */
+for (i = 0; i < vm->def->nnets; i++) {
+if (vm->def->nets[i]->ifname &&
+STREQ(vm->def->nets[i]->ifname, path)) {
+ret = virNetInterfaceStats(path, stats);
+break;
+}
+}
+
+ endjob:
+if (!libxlDomainObjEndJob(driver, vm)) {
+virObjectUnlock(vm);
+vm = NULL;
+}
+
+ cleanup:
+if (vm)
+virObjectUnlock(vm);
+return ret;
+}
+
+static int
 libxlDomainGetTotalCPUStats(libxlDriverPrivatePtr driver,
 virDomainObjPtr vm,
 virTypedParameterPtr params,
@@ -5411,6 +5458,7 @@ static virHypervisorDriver libxlHypervisorDriver = {
 #endif
 .nodeGetFreeMemory = libxlNodeGetFreeMemory, /* 0.9.0 */
 .nodeGetCellsFreeMemory = libxlNodeGetCellsFreeMemory, /* 1.1.1 */
+.domainInterfaceStats = libxlDomainInterfaceStats, /* 1.2.22 */
 .domainMemoryStats = libxlDomainMemoryStats, /* 1.2.22 */
 .domainGetCPUStats = libxlDomainGetCPUStats, /* 1.2.22 */
 .connectDomainEventRegister = libxlConnectDomainEventRegister, /* 0.9.0 */
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH v2 1/8] xen: arm: fix indendation of struct vtimer

2015-11-10 Thread Ian Campbell
Signed-off-by: Ian Campbell 
---
 xen/include/asm-arm/domain.h | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h
index e7e40da..c56f06e 100644
--- a/xen/include/asm-arm/domain.h
+++ b/xen/include/asm-arm/domain.h
@@ -35,11 +35,11 @@ extern int dom0_11_mapping;
 #define is_domain_direct_mapped(d) ((d) == hardware_domain && dom0_11_mapping)
 
 struct vtimer {
-struct vcpu *v;
-int irq;
-struct timer timer;
-uint32_t ctl;
-uint64_t cval;
+struct vcpu *v;
+int irq;
+struct timer timer;
+uint32_t ctl;
+uint64_t cval;
 };
 
 struct arch_domain
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH v2 8/8] HACK: Force virt timer to PPI0 (IRQ16)

2015-11-10 Thread Ian Campbell
Just for testing so the guest vtimer ppi it isn't the same as the
physical virt timer PPI on my platform, and therefore allows to
exercise the non-1:1 bits of the code.
---
 xen/include/public/arch-arm.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/include/public/arch-arm.h b/xen/include/public/arch-arm.h
index 6322548..01dbb41 100644
--- a/xen/include/public/arch-arm.h
+++ b/xen/include/public/arch-arm.h
@@ -432,7 +432,7 @@ typedef uint64_t xen_callback_t;
 #define GUEST_RAM_BANK_SIZES   { GUEST_RAM0_SIZE, GUEST_RAM1_SIZE }
 
 /* Interrupts */
-#define GUEST_TIMER_VIRT_PPI27
+#define GUEST_TIMER_VIRT_PPI16
 #define GUEST_TIMER_PHYS_S_PPI  29
 #define GUEST_TIMER_PHYS_NS_PPI 30
 #define GUEST_EVTCHN_PPI31
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH v2 4/8] xen: arm: remove vgic_vcpu_inject_spi()

2015-11-10 Thread Ian Campbell
Currently this has only a single caller, which I intend to teach about
injecting PPIs shortly. This helper doesn't add much so remove it.

Drop a stray tab from the comment immediately preceding this change.

Signed-off-by: Ian Campbell 
---
 xen/arch/arm/irq.c |  7 +--
 xen/arch/arm/vgic.c| 11 ---
 xen/include/asm-arm/vgic.h |  1 -
 3 files changed, 5 insertions(+), 14 deletions(-)

diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
index 6918438..5b073d1 100644
--- a/xen/arch/arm/irq.c
+++ b/xen/arch/arm/irq.c
@@ -214,6 +214,7 @@ void do_IRQ(struct cpu_user_regs *regs, unsigned int irq, 
int is_fiq)
 if ( test_bit(_IRQ_GUEST, >status) )
 {
 struct irq_guest *info = irq_get_guest_info(desc);
+struct vcpu *v;
 
 perfc_incr(guest_irqs);
 desc->handler->end(desc);
@@ -223,8 +224,10 @@ void do_IRQ(struct cpu_user_regs *regs, unsigned int irq, 
int is_fiq)
 /*
  * The irq cannot be a PPI, we only support delivery of SPIs to
  * guests.
-*/
-vgic_vcpu_inject_spi(info->d, info->virq);
+ */
+v = vgic_get_target_vcpu(info->d->vcpu[0], info->virq);
+vgic_vcpu_inject_irq(v, info->virq);
+
 goto out_no_end;
 }
 
diff --git a/xen/arch/arm/vgic.c b/xen/arch/arm/vgic.c
index 7bb4570..7a76f00 100644
--- a/xen/arch/arm/vgic.c
+++ b/xen/arch/arm/vgic.c
@@ -477,17 +477,6 @@ out:
 }
 }
 
-void vgic_vcpu_inject_spi(struct domain *d, unsigned int virq)
-{
-struct vcpu *v;
-
-/* the IRQ needs to be an SPI */
-ASSERT(virq >= 32 && virq <= vgic_num_irqs(d));
-
-v = vgic_get_target_vcpu(d->vcpu[0], virq);
-vgic_vcpu_inject_irq(v, virq);
-}
-
 void arch_evtchn_inject(struct vcpu *v)
 {
 vgic_vcpu_inject_irq(v, v->domain->arch.evtchn_irq);
diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h
index 7d580cc..aa675cb 100644
--- a/xen/include/asm-arm/vgic.h
+++ b/xen/include/asm-arm/vgic.h
@@ -207,7 +207,6 @@ extern void domain_vgic_free(struct domain *d);
 extern int vcpu_vgic_init(struct vcpu *v);
 extern struct vcpu *vgic_get_target_vcpu(struct vcpu *v, unsigned int irq);
 extern void vgic_vcpu_inject_irq(struct vcpu *v, unsigned int virq);
-extern void vgic_vcpu_inject_spi(struct domain *d, unsigned int virq);
 extern void vgic_clear_pending_irqs(struct vcpu *v);
 extern struct pending_irq *irq_to_pending(struct vcpu *v, unsigned int irq);
 extern struct pending_irq *spi_to_pending(struct domain *d, unsigned int irq);
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v8 13/21] xen/x86: make sure the HVM callback vector is correctly set

2015-11-10 Thread Jan Beulich
>>> On 06.11.15 at 17:05,  wrote:
> --- a/xen/arch/x86/hvm/irq.c
> +++ b/xen/arch/x86/hvm/irq.c
> @@ -330,6 +330,10 @@ void hvm_set_callback_via(struct domain *d, uint64_t via)
>   (via_type > HVMIRQ_callback_vector) )
>  via_type = HVMIRQ_callback_none;
>  
> +if ( via_type != HVMIRQ_callback_vector &&
> + (!has_vlapic(d) || !has_vioapic(d)) )
> +return;

What about PIC? With vpic_irq_positive_edge() now asserting
has_vpic(), and hvm_set_callback_irq_level() calling the former,
I don't think the above is sufficient.

Jan


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v2 5/6] multiboot2: Add support for relocatable images

2015-11-10 Thread Daniel Kiper
On Mon, Nov 09, 2015 at 09:08:35PM +0100, Vladimir 'φ-coder/phcoder' Serbinenko 
wrote:
> On 20.07.2015 16:35, Daniel Kiper wrote:
> > Signed-off-by: Daniel Kiper 
> What is handling the actual relocation?

In Xen we get image offset from GRUB2 and using this value we calculate
relative addresses. We are using %fs for it.

> Why doesn't this patch include support for ELF relocations?

This is another option. We considered it too. However, in our case
relative addressing looks simpler then ELF relocations. However, if
you wish I can add this functionality when this patch series is
included in upstream GRUB2. Is it OK for you?

Daniel

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v2 7/7] xen/arm: set the system time in Xen via the XENPF_settime64 hypercall

2015-11-10 Thread Stefano Stabellini
On Tue, 10 Nov 2015, Arnd Bergmann wrote:
> On Tuesday 10 November 2015 11:57:55 Stefano Stabellini wrote:
> > +   op.u.settime64.nsecs = now.tv_nsec;
> > +   op.u.settime64.system_time = arch_timer_read_counter() * 
> > (u64)NSEC_PER_SEC;
> > +   do_div(op.u.settime64.system_time, arch_timer_get_rate());
> 
> NSEC_PER_SEC is a large number, doesn't that multiplication overflow the
> 64-bit system_time variable?

It could be a concern, you are right. I think I can solve this issue and
remove multiple do_divs by calculating nsec_per_tick at initialization
time and use it here and in xen_read_wallclock.


> > +   printk("GTOD: Setting to %llu.%u at %llu\n",
> 
>  %llu.%09u
> 
> so you get the leading zeroes.
> 
> > +  op.u.settime64.secs,
> > +  op.u.settime64.nsecs,
> > +  op.u.settime64.system_time);
> > +   (void)HYPERVISOR_platform_op();
> 
>   Arnd
> 

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v2] tools/ocaml/xb: Correct calculations of data/space the ring

2015-11-10 Thread Samuel Thibault
Wei Liu, on Tue 10 Nov 2015 15:09:33 +, wrote:
> On Tue, Nov 10, 2015 at 04:06:13PM +0100, Samuel Thibault wrote:
> > Wei Liu, on Tue 10 Nov 2015 14:59:17 +, wrote:
> > > I think I will port this patch to cxenstored at some point. As far as I
> > > can tell cxenstored's data / space calculation is bogus in the same way.
> > 
> > The low-level function return short reads and writes, yes, but that is
> > handled at a higher level: initialize_fds sets timeout to 0 when there
> > is still room (domain_can_read() or domain_can_write()). So it will
> > improve performance a little bit, but not fix actual bugs.
> > 
> 
> Yeah, that's true. Just IMHO it would be better if we can actually make
> low level routine correct. That's orthogonal to what the upper layer is
> doing and should prevent latent bug if upper layer logic changes.

Agreed.

Samuel

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64

2015-11-10 Thread John Stultz
On Tue, Nov 10, 2015 at 7:10 AM, Stefano Stabellini
 wrote:
> On Tue, 10 Nov 2015, Arnd Bergmann wrote:
>> On Tuesday 10 November 2015 11:57:49 Stefano Stabellini wrote:
>> > __current_kernel_time64 returns a struct timespec64, without taking the
>> > xtime lock. Mirrors __current_kernel_time/current_kernel_time.
>> >
>>
>> Actually it doesn't mirror __current_kernel_time/current_kernel_time
>>
>> > diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
>> > index ec89d84..b5802bf 100644
>> > --- a/include/linux/timekeeping.h
>> > +++ b/include/linux/timekeeping.h
>> > @@ -19,7 +19,8 @@ extern int do_sys_settimeofday(const struct timespec *tv,
>> >   */
>> >  unsigned long get_seconds(void);
>> >  struct timespec64 current_kernel_time64(void);
>> > -/* does not take xtime_lock */
>> > +/* do not take xtime_lock */
>> > +struct timespec64 __current_kernel_time64(void);
>> >  struct timespec __current_kernel_time(void);
>>
>> Please change __current_kernel_time into a static inline function
>> while you are introducing the new one, to match the patch description ;-)
>
> The implementation is:
>
> struct timekeeper *tk = _core.timekeeper;
>
> return timespec64_to_timespec(tk_xtime(tk));
>
> which cannot be easily made into a static inline, unless we start
> exporting tk_core.

So the timekeeper is passed to the notifier. So you probably want something like

struct timespec64 __current_kernel_time64(struct timekeeper *tk)
{
 return timespec64_to_timespec(tk_xtime(tk));
}

Then you can cast the priv pointer in the notifier to a timekeeper and
use it that way?

thanks
-john

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH v2 7/8] libxl: implement virDomainGetJobInfo

2015-11-10 Thread Joao Martins
Introduce support for domainGetJobInfo to get info about the
ongoing job. If the job is active it will update the
timeElapsed which is computed with the "started" field added to
struct libxlDomainJobObj.  For now we support just the very basic
info and all jobs have VIR_DOMAIN_JOB_UNBOUNDED (i.e. no completion
time estimation) plus timeElapsed computed.

Openstack Kilo uses the Job API to monitor live-migration
progress which is currently nonexistent in libxl driver and
therefore leads to a crash in the nova compute node. Right
now, migration doesn't use jobs in the source node and will
return VIR_DOMAIN_JOB_NONE. Though nova handles this case and
will migrate it properly instead of crashing.

Signed-off-by: Joao Martins 
---
Changes since v1:
 - s/inexistent/nonexistent/g in commit message
 - s/estimed/estimated/g
 - Bump version to 1.2.22
---
 src/libxl/libxl_domain.c | 28 
 src/libxl/libxl_domain.h |  6 ++
 src/libxl/libxl_driver.c | 38 ++
 3 files changed, 72 insertions(+)

diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c
index 4fbb3fc..0411e9b 100644
--- a/src/libxl/libxl_domain.c
+++ b/src/libxl/libxl_domain.c
@@ -74,6 +74,10 @@ libxlDomainObjInitJob(libxlDomainObjPrivatePtr priv)
 if (virCondInit(>job.cond) < 0)
 return -1;
 
+if (VIR_ALLOC(priv->job.current) < 0)
+return -1;
+
+memset(priv->job.current, 0, sizeof(*(priv->job.current)));
 return 0;
 }
 
@@ -90,6 +94,7 @@ static void
 libxlDomainObjFreeJob(libxlDomainObjPrivatePtr priv)
 {
 ignore_value(virCondDestroy(>job.cond));
+VIR_FREE(priv->job.current);
 }
 
 /* Give up waiting for mutex after 30 seconds */
@@ -131,6 +136,8 @@ libxlDomainObjBeginJob(libxlDriverPrivatePtr driver 
ATTRIBUTE_UNUSED,
 VIR_DEBUG("Starting job: %s", libxlDomainJobTypeToString(job));
 priv->job.active = job;
 priv->job.owner = virThreadSelfID();
+priv->job.started = now;
+priv->job.current->type = VIR_DOMAIN_JOB_UNBOUNDED;
 
 return 0;
 
@@ -179,6 +186,27 @@ libxlDomainObjEndJob(libxlDriverPrivatePtr driver 
ATTRIBUTE_UNUSED,
 return virObjectUnref(obj);
 }
 
+int
+libxlDomainJobUpdateTime(struct libxlDomainJobObj *job)
+{
+virDomainJobInfoPtr jobInfo = job->current;
+unsigned long long now;
+
+if (!job->started)
+return 0;
+
+if (virTimeMillisNow() < 0)
+return -1;
+
+if (now < job->started) {
+job->started = 0;
+return 0;
+}
+
+jobInfo->timeElapsed = now - job->started;
+return 0;
+}
+
 static void *
 libxlDomainObjPrivateAlloc(void)
 {
diff --git a/src/libxl/libxl_domain.h b/src/libxl/libxl_domain.h
index 44b3e0b..1c1eba3 100644
--- a/src/libxl/libxl_domain.h
+++ b/src/libxl/libxl_domain.h
@@ -53,6 +53,8 @@ struct libxlDomainJobObj {
 virCond cond;   /* Use to coordinate jobs */
 enum libxlDomainJob active; /* Currently running job */
 int owner;  /* Thread which set current job */
+unsigned long long started; /* When the job started */
+virDomainJobInfoPtr current;/* Statistics for the current job */
 };
 
 typedef struct _libxlDomainObjPrivate libxlDomainObjPrivate;
@@ -88,6 +90,10 @@ libxlDomainObjEndJob(libxlDriverPrivatePtr driver,
  virDomainObjPtr obj)
 ATTRIBUTE_RETURN_CHECK;
 
+int
+libxlDomainJobUpdateTime(struct libxlDomainJobObj *job)
+ATTRIBUTE_RETURN_CHECK;
+
 void
 libxlDomainEventQueue(libxlDriverPrivatePtr driver,
   virObjectEventPtr event);
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 8db6536..b0b6ea7 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -5236,6 +5236,43 @@ libxlDomainMemoryStats(virDomainPtr dom,
 return ret;
 }
 
+static int
+libxlDomainGetJobInfo(virDomainPtr dom,
+  virDomainJobInfoPtr info)
+{
+libxlDomainObjPrivatePtr priv;
+virDomainObjPtr vm;
+int ret = -1;
+
+if (!(vm = libxlDomObjFromDomain(dom)))
+goto cleanup;
+
+if (virDomainGetJobInfoEnsureACL(dom->conn, vm->def) < 0)
+goto cleanup;
+
+priv = vm->privateData;
+if (!priv->job.active) {
+memset(info, 0, sizeof(*info));
+info->type = VIR_DOMAIN_JOB_NONE;
+ret = 0;
+goto cleanup;
+}
+
+/* In libxl we don't have an estimated completion time
+ * thus we always set to unbounded and update time
+ * for the active job. */
+if (libxlDomainJobUpdateTime(>job) < 0)
+goto cleanup;
+
+memcpy(info, priv->job.current, sizeof(virDomainJobInfo));
+ret = 0;
+
+ cleanup:
+if (vm)
+virObjectUnlock(vm);
+return ret;
+}
+
 #undef LIBXL_SET_MEMSTAT
 
 #define LIBXL_RECORD_UINT(error, key, value, ...) \
@@ -6096,6 +6133,7 @@ static virHypervisorDriver libxlHypervisorDriver = {
 #endif
 .nodeGetFreeMemory = 

[Xen-devel] [PATCH v2 5/8] libxl: implement virDomainBlockStats

2015-11-10 Thread Joao Martins
Introduce initial support for domainBlockStats API call that
allow us to query block device statistics. openstack nova
uses this API call to query block statistics, alongside
virDomainMemoryStats and virDomainInterfaceStats.  Note that
this patch only introduces it for VBD for starters. QDisk
will come in a separate patch series.

A new statistics data structure is introduced to fit common
statistics among others specific to the underlying block
backends. For the VBD statistics on linux these are exported
via sysfs on the path:

"/sys/bus/xen-backend/devices/vbd--/statistics"

To calculate the block devno libxlDiskPathToID is introduced.
Each backend implements its own function to extract statistics
and let there be handled the different platforms. An alternative
would be to reuse libvirt xen driver function.

VBD stats are exposed in reqs and number of sectors from
blkback, and it's up to us to convert it to sector sizes.
The sector size is gathered through xenstore in the device
backend entry "physical-sector-size". This adds up an extra
dependency namely of xenstore for doing the xs_read.

BlockStatsFlags variant is also implemented which has the
added benefit of getting the number of flush requests.

Signed-off-by: Joao Martins 
---
Changes since v1:
 - Fix identation issues
 - Set ret to LIBXL_VBD_SECTOR_SIZE
 - Reuse VIR_STRDUP error instead of doing virReportError
 when we fail to set stats->backend
 - Change virAsprintf(...) error checking
 - Change error to VIR_ERR_OPERATION_FAILED when xenstore path
 does not exist and when failing to read stat.
 - Resolve issues with 'make syntax-check' with cppi installed.
 - Remove libxlDiskPathMatches in favor of using virutil
 virDiskNameParse to fetch disk and partition index.
 - Rename libxlDiskPathParse to libxlDiskPathToID and rework
 function to just convert disk and partition index to devno.
 - Bump version to 1.2.22
---
 configure.ac |   2 +-
 src/libxl/libxl_driver.c | 375 +++
 2 files changed, 376 insertions(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index f481c50..10c56e5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -896,7 +896,7 @@ if test "$with_libxl" != "no" ; then
 LIBS="$LIBS $LIBXL_LIBS"
 AC_CHECK_LIB([xenlight], [libxl_ctx_alloc], [
 with_libxl=yes
-LIBXL_LIBS="$LIBXL_LIBS -lxenlight -lxenctrl"
+LIBXL_LIBS="$LIBXL_LIBS -lxenlight -lxenctrl -lxenstore"
 ],[
 if test "$with_libxl" = "yes"; then
 fail=1
diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 9a5a74c..ba1d67b 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -59,6 +59,7 @@
 #include "network/bridge_driver.h"
 #include "locking/domain_lock.h"
 #include "virstats.h"
+#include 
 
 #define VIR_FROM_THIS VIR_FROM_LIBXL
 
@@ -75,6 +76,7 @@ VIR_LOG_INIT("libxl.libxl_driver");
 #define LIBXL_CONFIG_FORMAT_SEXPR "xen-sxpr"
 
 #define LIBXL_NB_TOTAL_CPU_STAT_PARAM 1
+#define LIBXL_NB_TOTAL_BLK_STAT_PARAM 6
 
 #define HYPERVISOR_CAPABILITIES "/proc/xen/capabilities"
 #define HYPERVISOR_XENSTORED "/dev/xen/xenstored"
@@ -103,6 +105,25 @@ struct _libxlOSEventHookInfo {
 int id;
 };
 
+/* Object used to store disk statistics across multiple xen backends */
+typedef struct _libxlBlockStats libxlBlockStats;
+typedef libxlBlockStats *libxlBlockStatsPtr;
+struct _libxlBlockStats {
+long long rd_req;
+long long rd_bytes;
+long long wr_req;
+long long wr_bytes;
+long long f_req;
+
+char *backend;
+union {
+struct {
+long long ds_req;
+long long oo_req;
+} vbd;
+} u;
+};
+
 /* Function declarations */
 static int
 libxlDomainManagedSaveLoad(virDomainObjPtr vm,
@@ -4644,6 +4665,358 @@ libxlDomainIsUpdated(virDomainPtr dom)
 }
 
 static int
+libxlDiskPathToID(const char *virtpath)
+{
+static char const* drive_prefix[] = {"xvd", "hd", "sd"};
+int disk, partition, chrused;
+int fmt, id;
+char *r;
+size_t i;
+
+fmt = id = -1;
+
+/* Find any disk prefixes we know about */
+for (i = 0; i < ARRAY_CARDINALITY(drive_prefix); i++) {
+if (STRPREFIX(virtpath, drive_prefix[i]) &&
+!virDiskNameParse(virtpath, , )) {
+fmt = i;
+break;
+}
+}
+
+/* Handle it same way as xvd */
+if (fmt < 0 &&
+(sscanf(virtpath, "d%ip%i%n", , , ) >= 2
+ && chrused == strlen(virtpath)))
+fmt = 0;
+
+/* Test indexes ranges and calculate the device id */
+switch (fmt) {
+case 0: /* xvd */
+if (disk <= 15 && partition <= 15)
+id = (202 << 8) | (disk << 4) | partition;
+else if ((disk <= ((1<<20)-1)) || partition <= 255)
+id = (1 << 28) | (disk << 8) | partition;
+break;
+case 1: /* hd */
+if (disk <= 3 && partition <= 63)
+id = ((disk < 2 

[Xen-devel] [PATCH v2 6/8] libxl: implement virConnectGetAllDomainStats

2015-11-10 Thread Joao Martins
Introduce support for connectGetAllDomainStats call that
allow us to _all_ domain(s) statistics including network, block,
cpus and memory. Changes are rather mechanical and mostly
take care of the format to export the data.

Signed-off-by: Joao Martins 
---
Changes since v1:
 - Rework flags checking on libxlDomainGetStats
 for VIR_DOMAIN_STATS_{VCPU,INTERFACE,BLOCK}
 - Removed path since we are reusing .ifname
 - Init dominfo and dispose it on cleanup.
 - Fixed VIR_FREE issue that was reported with make syntax-check"
 - Bump version to 1.2.22
---
 src/libxl/libxl_driver.c | 266 +++
 1 file changed, 266 insertions(+)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index ba1d67b..8db6536 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -5238,6 +5238,271 @@ libxlDomainMemoryStats(virDomainPtr dom,
 
 #undef LIBXL_SET_MEMSTAT
 
+#define LIBXL_RECORD_UINT(error, key, value, ...) \
+do { \
+char param_name[VIR_TYPED_PARAM_FIELD_LENGTH]; \
+snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, \
+ key, ##__VA_ARGS__); \
+if (virTypedParamsAddUInt(>params, \
+  >nparams, \
+  , \
+  param_name, \
+  value) < 0) \
+goto error;   \
+} while (0)
+
+#define LIBXL_RECORD_LL(error, key, value, ...) \
+do { \
+char param_name[VIR_TYPED_PARAM_FIELD_LENGTH]; \
+snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, \
+ key, ##__VA_ARGS__); \
+if (virTypedParamsAddLLong(>params, \
+   >nparams, \
+   , \
+   param_name, \
+   value) < 0) \
+goto error; \
+} while (0)
+
+#define LIBXL_RECORD_ULL(error, key, value, ...) \
+do { \
+char param_name[VIR_TYPED_PARAM_FIELD_LENGTH]; \
+snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, \
+ key, ##__VA_ARGS__); \
+if (virTypedParamsAddULLong(>params, \
+>nparams, \
+, \
+param_name, \
+value) < 0) \
+goto error; \
+} while (0)
+
+#define LIBXL_RECORD_STR(error, key, value, ...) \
+do { \
+char param_name[VIR_TYPED_PARAM_FIELD_LENGTH]; \
+snprintf(param_name, VIR_TYPED_PARAM_FIELD_LENGTH, \
+ key, ##__VA_ARGS__); \
+if (virTypedParamsAddString(>params, \
+>nparams, \
+, \
+param_name, \
+value) < 0) \
+goto error; \
+} while (0)
+
+static int
+libxlDomainGetStats(virConnectPtr conn,
+virDomainObjPtr dom,
+unsigned int stats,
+virDomainStatsRecordPtr *record)
+{
+libxlDriverPrivatePtr driver = conn->privateData;
+libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
+virDomainStatsRecordPtr tmp;
+libxl_dominfo d_info;
+libxl_vcpuinfo *vcpuinfo = NULL;
+int maxcpu, hostcpus;
+unsigned long long mem, maxmem;
+int maxparams = 0;
+int ret = -1;
+size_t i, state;
+unsigned int domflags = stats & (VIR_DOMAIN_STATS_BALLOON |
+ VIR_DOMAIN_STATS_CPU_TOTAL);
+
+if (VIR_ALLOC(tmp) < 0)
+return ret;
+
+libxl_dominfo_init(_info);
+
+mem = virDomainDefGetMemoryInitial(dom->def);
+maxmem = virDomainDefGetMemoryActual(dom->def);
+d_info.cpu_time = 0;
+
+if (domflags && virDomainObjIsActive(dom) &&
+!libxl_domain_info(cfg->ctx, _info, dom->def->id)) {
+mem = d_info.current_memkb;
+maxmem = d_info.max_memkb;
+}
+
+if (stats & VIR_DOMAIN_STATS_STATE) {
+LIBXL_RECORD_UINT(cleanup, "state.reason", dom->state.reason);
+LIBXL_RECORD_UINT(cleanup, "state.state", dom->state.state);
+}
+
+if (stats & VIR_DOMAIN_STATS_BALLOON) {
+LIBXL_RECORD_ULL(cleanup, "balloon.current", mem);
+LIBXL_RECORD_ULL(cleanup, "balloon.maximum", maxmem);
+}
+
+if (stats & VIR_DOMAIN_STATS_CPU_TOTAL)
+LIBXL_RECORD_ULL(cleanup, "cpu.time", d_info.cpu_time);
+
+if (stats & VIR_DOMAIN_STATS_VCPU) {
+vcpuinfo = libxl_list_vcpu(cfg->ctx, dom->def->id, , );
+
+for (i = 0; i < dom->def->vcpus; i++) {
+if (!vcpuinfo)
+state = VIR_VCPU_OFFLINE;
+else if (vcpuinfo[i].running)
+state = VIR_VCPU_RUNNING;
+else if (vcpuinfo[i].blocked)
+state = VIR_VCPU_BLOCKED;
+else
+state = VIR_VCPU_OFFLINE;
+
+LIBXL_RECORD_UINT(cleanup_vcpu, "vcpu.%zu.state", state, 

[Xen-devel] [PATCH v2 0/8] libxl: domain statistics support

2015-11-10 Thread Joao Martins
Hey,

This series bring support for various statistics about domains
regarding CPU, Memory, Network Interfaces, Block and Jobs. Not all of
the statistics are implemented: qdisk support is missing in this series
and some of the memory statistics aren't available.

With this series we further implement 7 more functions of libvirt APIs.
It is organized as follows:

 * Patch 1, 2: implements cpu/memory statistics.
 * Patch 3: implements network statistics
 * Patch 4: adds helper method virDiskNameParse as an extension
to virDiskNameToIndex (New)
 * Patch 5: VBD block statistics. QDisk will follow up in a separate
series regarding QEMU monitor integration.
 * Patch 6: implement fetching all domain statistics
 * Patch 7, 8: implements Job information statistics.

Overall it looks big but 70% of the patch is due to #5 and #6 but doesn't
add necessarily more complexity to the driver I believe. Patch #7 and #8
are of special importance because GetJobInfo and GetJobStats are now used
in Openstack Kilo to monitor live-migration progress. These two patches
together with the p2p migration I sent earlier let us sucessfully
live-migrate with Openstack Kilo. Furthermore with this series we get to
support nova diagnostics.

Tested this series on 4.4.3 and 4.5 setups plus Openstack Kilo.

Individual patches contain the changelog and comments addressed since v1.

Thanks!

Joao Martins (8):
  libxl: implement virDomainGetCPUStats
  libxl: implement virDomainMemorystats
  libxl: implement virDomainInterfaceStats
  util: add virDiskNameParse to handle disk and partition idx
  libxl: implement virDomainBlockStats
  libxl: implement virConnectGetAllDomainStats
  libxl: implement virDomainGetJobInfo
  libxl: implement virDomainGetJobStats

 configure.ac |   2 +-
 src/libvirt_private.syms |   1 +
 src/libxl/libxl_domain.c |  43 +++
 src/libxl/libxl_domain.h |   6 +
 src/libxl/libxl_driver.c | 960 +++
 src/util/virutil.c   |  41 +-
 src/util/virutil.h   |   1 +
 tests/utiltest.c |  56 +++
 8 files changed, 1105 insertions(+), 5 deletions(-)

-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH v2 8/8] libxl: implement virDomainGetJobStats

2015-11-10 Thread Joao Martins
Introduces support for domainGetJobStats which has the same
info as domainGetJobInfo but in a slightly different format.
Another difference is that virDomainGetJobStats can also
retrieve info on the most recently completed job. Though so
far this is only used in the source node to know if the
migration has been completed. But because we don't support
completed jobs we will deliver an error.

Signed-off-by: Joao Martins 
---
Changes since v1:
 - Fixed indentation on libxlDomainGetJobStats()
 - s/estimed/estimated/g
 - Bump version to 1.2.22
---
 src/libxl/libxl_driver.c | 53 
 1 file changed, 53 insertions(+)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index b0b6ea7..dda14c2 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -5273,6 +5273,58 @@ libxlDomainGetJobInfo(virDomainPtr dom,
 return ret;
 }
 
+static int
+libxlDomainGetJobStats(virDomainPtr dom,
+   int *type,
+   virTypedParameterPtr *params,
+   int *nparams,
+   unsigned int flags)
+{
+libxlDomainObjPrivatePtr priv;
+virDomainObjPtr vm;
+virDomainJobInfoPtr jobInfo;
+int ret = -1;
+int maxparams = 0;
+
+/* VIR_DOMAIN_JOB_STATS_COMPLETED not supported yet */
+virCheckFlags(0, -1);
+
+if (!(vm = libxlDomObjFromDomain(dom)))
+goto cleanup;
+
+if (virDomainGetJobStatsEnsureACL(dom->conn, vm->def) < 0)
+goto cleanup;
+
+priv = vm->privateData;
+jobInfo = priv->job.current;
+if (!priv->job.active) {
+*type = VIR_DOMAIN_JOB_NONE;
+*params = NULL;
+*nparams = 0;
+ret = 0;
+goto cleanup;
+}
+
+/* In libxl we don't have an estimated completion time
+ * thus we always set to unbounded and update time
+ * for the active job. */
+if (libxlDomainJobUpdateTime(>job) < 0)
+goto cleanup;
+
+if (virTypedParamsAddULLong(params, nparams, ,
+VIR_DOMAIN_JOB_TIME_ELAPSED,
+jobInfo->timeElapsed) < 0)
+goto cleanup;
+
+*type = jobInfo->type;
+ret = 0;
+
+ cleanup:
+if (vm)
+virObjectUnlock(vm);
+return ret;
+}
+
 #undef LIBXL_SET_MEMSTAT
 
 #define LIBXL_RECORD_UINT(error, key, value, ...) \
@@ -6134,6 +6186,7 @@ static virHypervisorDriver libxlHypervisorDriver = {
 .nodeGetFreeMemory = libxlNodeGetFreeMemory, /* 0.9.0 */
 .nodeGetCellsFreeMemory = libxlNodeGetCellsFreeMemory, /* 1.1.1 */
 .domainGetJobInfo = libxlDomainGetJobInfo, /* 1.2.22 */
+.domainGetJobStats = libxlDomainGetJobStats, /* 1.2.22 */
 .domainBlockStats = libxlDomainBlockStats, /* 1.2.22 */
 .domainBlockStatsFlags = libxlDomainBlockStatsFlags, /* 1.2.22 */
 .domainInterfaceStats = libxlDomainInterfaceStats, /* 1.2.22 */
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH v2 1/8] libxl: implement virDomainGetCPUStats

2015-11-10 Thread Joao Martins
Introduce support for domainGetCPUStats API call and consequently
allow us to use `virsh cpu-stats`. The latter returns a more brief
output than the one provided by`virsh vcpuinfo`.

Signed-off-by: Joao Martins 
---
Changes since v1:
 - Remove libxl_vcpuinfo_dispose() in favor or using
 libxl_vcpuinfo_list_free(), and also removing VIR_FREE call
 - Dispose libxl_dominfo after succesfull call to
 libxl_domain_info()
 - Fixed identation of parameters
 - Bump version to 1.2.22
---
 src/libxl/libxl_driver.c | 110 +++
 1 file changed, 110 insertions(+)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index fcdcbdb..50f6e34 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -73,6 +73,8 @@ VIR_LOG_INIT("libxl.libxl_driver");
 #define LIBXL_CONFIG_FORMAT_XM "xen-xm"
 #define LIBXL_CONFIG_FORMAT_SEXPR "xen-sxpr"
 
+#define LIBXL_NB_TOTAL_CPU_STAT_PARAM 1
+
 #define HYPERVISOR_CAPABILITIES "/proc/xen/capabilities"
 #define HYPERVISOR_XENSTORED "/dev/xen/xenstored"
 
@@ -4641,6 +4643,113 @@ libxlDomainIsUpdated(virDomainPtr dom)
 }
 
 static int
+libxlDomainGetTotalCPUStats(libxlDriverPrivatePtr driver,
+virDomainObjPtr vm,
+virTypedParameterPtr params,
+unsigned int nparams)
+{
+libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
+libxl_dominfo d_info;
+int ret = -1;
+
+if (nparams == 0)
+return LIBXL_NB_TOTAL_CPU_STAT_PARAM;
+
+if (libxl_domain_info(cfg->ctx, _info, vm->def->id) != 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("libxl_domain_info failed for domain '%d'"),
+   vm->def->id);
+return ret;
+}
+
+if (virTypedParameterAssign([0], VIR_DOMAIN_CPU_STATS_CPUTIME,
+VIR_TYPED_PARAM_ULLONG, d_info.cpu_time) < 0)
+nparams = ret;
+
+libxl_dominfo_dispose(_info);
+return nparams;
+}
+
+static int
+libxlDomainGetPerCPUStats(libxlDriverPrivatePtr driver,
+  virDomainObjPtr vm,
+  virTypedParameterPtr params,
+  unsigned int nparams,
+  int start_cpu,
+  unsigned int ncpus)
+{
+libxl_vcpuinfo *vcpuinfo;
+int maxcpu, hostcpus;
+size_t i;
+libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
+int ret = -1;
+
+if (nparams == 0 && ncpus != 0)
+return LIBXL_NB_TOTAL_CPU_STAT_PARAM;
+else if (nparams == 0)
+return vm->def->maxvcpus;
+
+if ((vcpuinfo = libxl_list_vcpu(cfg->ctx, vm->def->id, ,
+)) == NULL) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("Failed to list vcpus for domain '%d' with 
libxenlight"),
+   vm->def->id);
+return ret;
+}
+
+for (i = start_cpu; i < maxcpu && i < ncpus; ++i) {
+if (virTypedParameterAssign([(i-start_cpu)],
+VIR_DOMAIN_CPU_STATS_CPUTIME,
+VIR_TYPED_PARAM_ULLONG,
+vcpuinfo[i].vcpu_time) < 0)
+goto cleanup;
+}
+ret = nparams;
+
+ cleanup:
+libxl_vcpuinfo_list_free(vcpuinfo, maxcpu);
+return ret;
+}
+
+static int
+libxlDomainGetCPUStats(virDomainPtr dom,
+   virTypedParameterPtr params,
+   unsigned int nparams,
+   int start_cpu,
+   unsigned int ncpus,
+   unsigned int flags)
+{
+libxlDriverPrivatePtr driver = dom->conn->privateData;
+virDomainObjPtr vm = NULL;
+int ret = -1;
+
+virCheckFlags(VIR_TYPED_PARAM_STRING_OKAY, -1);
+
+if (!(vm = libxlDomObjFromDomain(dom)))
+goto cleanup;
+
+if (virDomainGetCPUStatsEnsureACL(dom->conn, vm->def) < 0)
+goto cleanup;
+
+if (!virDomainObjIsActive(vm)) {
+virReportError(VIR_ERR_OPERATION_INVALID,
+   "%s", _("domain is not running"));
+goto cleanup;
+}
+
+if (start_cpu == -1)
+ret = libxlDomainGetTotalCPUStats(driver, vm, params, nparams);
+else
+ret = libxlDomainGetPerCPUStats(driver, vm, params, nparams,
+  start_cpu, ncpus);
+
+ cleanup:
+if (vm)
+virObjectUnlock(vm);
+return ret;
+}
+
+static int
 libxlConnectDomainEventRegisterAny(virConnectPtr conn, virDomainPtr dom, int 
eventID,
virConnectDomainEventGenericCallback 
callback,
void *opaque, virFreeCallback freecb)
@@ -5233,6 +5342,7 @@ static virHypervisorDriver libxlHypervisorDriver = {
 #endif
 .nodeGetFreeMemory = libxlNodeGetFreeMemory, /* 0.9.0 */
 .nodeGetCellsFreeMemory = libxlNodeGetCellsFreeMemory, /* 

Re: [Xen-devel] [PATCH v2] tools/ocaml/xb: Correct calculations of data/space the ring

2015-11-10 Thread Samuel Thibault
Wei Liu, on Tue 10 Nov 2015 14:59:17 +, wrote:
> I think I will port this patch to cxenstored at some point. As far as I
> can tell cxenstored's data / space calculation is bogus in the same way.

The low-level function return short reads and writes, yes, but that is
handled at a higher level: initialize_fds sets timeout to 0 when there
is still room (domain_can_read() or domain_can_write()). So it will
improve performance a little bit, but not fix actual bugs.

Samuel

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v2] tools/ocaml/xb: Correct calculations of data/space the ring

2015-11-10 Thread Wei Liu
On Tue, Nov 10, 2015 at 04:06:13PM +0100, Samuel Thibault wrote:
> Wei Liu, on Tue 10 Nov 2015 14:59:17 +, wrote:
> > I think I will port this patch to cxenstored at some point. As far as I
> > can tell cxenstored's data / space calculation is bogus in the same way.
> 
> The low-level function return short reads and writes, yes, but that is
> handled at a higher level: initialize_fds sets timeout to 0 when there
> is still room (domain_can_read() or domain_can_write()). So it will
> improve performance a little bit, but not fix actual bugs.
> 

Yeah, that's true. Just IMHO it would be better if we can actually make
low level routine correct. That's orthogonal to what the upper layer is
doing and should prevent latent bug if upper layer logic changes.

Wei.

> Samuel

-- 
Wei.

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64

2015-11-10 Thread Stefano Stabellini
On Tue, 10 Nov 2015, Arnd Bergmann wrote:
> On Tuesday 10 November 2015 11:57:49 Stefano Stabellini wrote:
> > __current_kernel_time64 returns a struct timespec64, without taking the
> > xtime lock. Mirrors __current_kernel_time/current_kernel_time.
> > 
> 
> Actually it doesn't mirror __current_kernel_time/current_kernel_time
> 
> > diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
> > index ec89d84..b5802bf 100644
> > --- a/include/linux/timekeeping.h
> > +++ b/include/linux/timekeeping.h
> > @@ -19,7 +19,8 @@ extern int do_sys_settimeofday(const struct timespec *tv,
> >   */
> >  unsigned long get_seconds(void);
> >  struct timespec64 current_kernel_time64(void);
> > -/* does not take xtime_lock */
> > +/* do not take xtime_lock */
> > +struct timespec64 __current_kernel_time64(void);
> >  struct timespec __current_kernel_time(void);
> 
> Please change __current_kernel_time into a static inline function
> while you are introducing the new one, to match the patch description ;-)

The implementation is:

struct timekeeper *tk = _core.timekeeper;

return timespec64_to_timespec(tk_xtime(tk));

which cannot be easily made into a static inline, unless we start
exporting tk_core.

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH v2 2/8] libxl: implement virDomainMemorystats

2015-11-10 Thread Joao Martins
Introduce support for domainMemoryStats API call, which
consequently enables the use of `virsh dommemstat` command to
query for memory statistics of a domain. We support
the following statistics: balloon info, available and currently
in use. swap-in, swap-out, major-faults, minor-faults require
cooperation of the guest and thus currently not supported.

We build on the data returned from libxl_domain_info and deliver
it in the virDomainMemoryStat format.

Signed-off-by: Joao Martins 
---
Changes since v1:
 - Cleanup properly after error fetching domain stats
 - Dispose libxl_dominfo after succesfull call to
 libxl_domain_info()
 - Bump version to 1.2.22
---
 src/libxl/libxl_driver.c | 70 
 1 file changed, 70 insertions(+)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index 50f6e34..f4fc7bc 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -4749,6 +4749,75 @@ libxlDomainGetCPUStats(virDomainPtr dom,
 return ret;
 }
 
+#define LIBXL_SET_MEMSTAT(TAG, VAL) \
+if (i < nr_stats) { \
+stats[i].tag = TAG; \
+stats[i].val = VAL; \
+i++; \
+}
+
+static int
+libxlDomainMemoryStats(virDomainPtr dom,
+   virDomainMemoryStatPtr stats,
+   unsigned int nr_stats,
+   unsigned int flags)
+{
+libxlDriverPrivatePtr driver = dom->conn->privateData;
+libxlDriverConfigPtr cfg = libxlDriverConfigGet(driver);
+virDomainObjPtr vm;
+libxl_dominfo d_info;
+unsigned mem, maxmem;
+size_t i = 0;
+int ret = -1;
+
+virCheckFlags(0, -1);
+
+if (!(vm = libxlDomObjFromDomain(dom)))
+goto cleanup;
+
+if (virDomainMemoryStatsEnsureACL(dom->conn, vm->def) < 0)
+goto cleanup;
+
+if (libxlDomainObjBeginJob(driver, vm, LIBXL_JOB_QUERY) < 0)
+goto cleanup;
+
+if (!virDomainObjIsActive(vm)) {
+virReportError(VIR_ERR_OPERATION_INVALID,
+   "%s", _("domain is not running"));
+goto endjob;
+}
+
+if (libxl_domain_info(cfg->ctx, _info, vm->def->id) != 0) {
+virReportError(VIR_ERR_INTERNAL_ERROR,
+   _("libxl_domain_info failed for domain '%d'"),
+   vm->def->id);
+goto endjob;
+}
+mem = d_info.current_memkb;
+maxmem = d_info.max_memkb;
+
+LIBXL_SET_MEMSTAT(VIR_DOMAIN_MEMORY_STAT_ACTUAL_BALLOON, maxmem - mem);
+LIBXL_SET_MEMSTAT(VIR_DOMAIN_MEMORY_STAT_AVAILABLE, maxmem);
+LIBXL_SET_MEMSTAT(VIR_DOMAIN_MEMORY_STAT_RSS, mem);
+
+ret = i;
+
+libxl_dominfo_dispose(_info);
+
+ endjob:
+if (!libxlDomainObjEndJob(driver, vm)) {
+virObjectUnlock(vm);
+vm = NULL;
+}
+
+ cleanup:
+if (vm)
+virObjectUnlock(vm);
+return ret;
+}
+
+#undef LIBXL_SET_MEMSTAT
+
 static int
 libxlConnectDomainEventRegisterAny(virConnectPtr conn, virDomainPtr dom, int 
eventID,
virConnectDomainEventGenericCallback 
callback,
@@ -5342,6 +5411,7 @@ static virHypervisorDriver libxlHypervisorDriver = {
 #endif
 .nodeGetFreeMemory = libxlNodeGetFreeMemory, /* 0.9.0 */
 .nodeGetCellsFreeMemory = libxlNodeGetCellsFreeMemory, /* 1.1.1 */
+.domainMemoryStats = libxlDomainMemoryStats, /* 1.2.22 */
 .domainGetCPUStats = libxlDomainGetCPUStats, /* 1.2.22 */
 .connectDomainEventRegister = libxlConnectDomainEventRegister, /* 0.9.0 */
 .connectDomainEventDeregister = libxlConnectDomainEventDeregister, /* 
0.9.0 */
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64

2015-11-10 Thread Thomas Gleixner
On Tue, 10 Nov 2015, John Stultz wrote:
> On Tue, Nov 10, 2015 at 7:10 AM, Stefano Stabellini
>  wrote:
> > On Tue, 10 Nov 2015, Arnd Bergmann wrote:
> >> On Tuesday 10 November 2015 11:57:49 Stefano Stabellini wrote:
> >> > __current_kernel_time64 returns a struct timespec64, without taking the
> >> > xtime lock. Mirrors __current_kernel_time/current_kernel_time.
> >> >
> >>
> >> Actually it doesn't mirror __current_kernel_time/current_kernel_time
> >>
> >> > diff --git a/include/linux/timekeeping.h b/include/linux/timekeeping.h
> >> > index ec89d84..b5802bf 100644
> >> > --- a/include/linux/timekeeping.h
> >> > +++ b/include/linux/timekeeping.h
> >> > @@ -19,7 +19,8 @@ extern int do_sys_settimeofday(const struct timespec 
> >> > *tv,
> >> >   */
> >> >  unsigned long get_seconds(void);
> >> >  struct timespec64 current_kernel_time64(void);
> >> > -/* does not take xtime_lock */
> >> > +/* do not take xtime_lock */
> >> > +struct timespec64 __current_kernel_time64(void);
> >> >  struct timespec __current_kernel_time(void);
> >>
> >> Please change __current_kernel_time into a static inline function
> >> while you are introducing the new one, to match the patch description ;-)
> >
> > The implementation is:
> >
> > struct timekeeper *tk = _core.timekeeper;
> >
> > return timespec64_to_timespec(tk_xtime(tk));
> >
> > which cannot be easily made into a static inline, unless we start
> > exporting tk_core.
> 
> So the timekeeper is passed to the notifier. So you probably want something 
> like
> 
> struct timespec64 __current_kernel_time64(struct timekeeper *tk)
> {
>  return timespec64_to_timespec(tk_xtime(tk));
> }
> 
> Then you can cast the priv pointer in the notifier to a timekeeper and
> use it that way?

Err no. Look at commit 8758a240e2d74c5932ab51a73377e6507b7fd441

i.e. Add the new 64bit function and make the existing one a static
inline which does the timespec64 to timespec conversion.

Thanks,

tglx

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH v2] libxl: add p2p migration

2015-11-10 Thread Joao Martins
Introduce support for VIR_MIGRATE_PEER2PEER in libxl driver
for supporting migration in Openstack. Most of the changes
occur at the source and no modifications at the receiver.

In P2P mode there is only the Perform phase so we must handle
the connection with the destination and actually perform the
migration. libxlDomainPerformP2P implements the connection to
the destination and let libxlDoMigrateP2P implements the actual
migration logic with virConnectPtr. In this function we do
the migration steps in the destination similar to
virDomainMigrateVersion3Full. We appropriately save the last
error reported in each of the phases to provide proper
reporting. We don't yet support VIR_MIGRATE_TUNNELED and
we always use V3 with extensible params, making the
implementation simpler.

It is worth noting that the receiver didn't have any changes,
and because it's still the v3 sequence thus it is possible to
migrate from a P2P to non-P2P host.

Signed-off-by: Joao Martins 
---
Changes since v1:
 - Move Begin step to libxlDoMigrateP2P to have all 4 steps
 together.
 - Remove if before VIR_FREE(dom_xml)
---
 src/libxl/libxl_driver.c|  13 ++-
 src/libxl/libxl_migration.c | 220 
 src/libxl/libxl_migration.h |  11 +++
 3 files changed, 241 insertions(+), 3 deletions(-)

diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c
index fcdcbdb..da98265 100644
--- a/src/libxl/libxl_driver.c
+++ b/src/libxl/libxl_driver.c
@@ -4713,6 +4713,7 @@ libxlConnectSupportsFeature(virConnectPtr conn, int 
feature)
 switch (feature) {
 case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
 case VIR_DRV_FEATURE_MIGRATION_PARAMS:
+case VIR_DRV_FEATURE_MIGRATION_P2P:
 return 1;
 default:
 return 0;
@@ -5039,9 +5040,15 @@ libxlDomainMigratePerform3Params(virDomainPtr dom,
 if (virDomainMigratePerform3ParamsEnsureACL(dom->conn, vm->def) < 0)
 goto cleanup;
 
-if (libxlDomainMigrationPerform(driver, vm, dom_xml, dconnuri,
-uri, dname, flags) < 0)
-goto cleanup;
+if (flags & VIR_MIGRATE_PEER2PEER) {
+if (libxlDomainMigrationPerformP2P(driver, vm, dom->conn, dom_xml,
+   dconnuri, uri, dname, flags) < 0)
+goto cleanup;
+} else {
+if (libxlDomainMigrationPerform(driver, vm, dom_xml, dconnuri,
+uri, dname, flags) < 0)
+goto cleanup;
+}
 
 ret = 0;
 
diff --git a/src/libxl/libxl_migration.c b/src/libxl/libxl_migration.c
index 0d23e5f..a1c7b55 100644
--- a/src/libxl/libxl_migration.c
+++ b/src/libxl/libxl_migration.c
@@ -42,6 +42,7 @@
 #include "libxl_conf.h"
 #include "libxl_migration.h"
 #include "locking/domain_lock.h"
+#include "virtypedparam.h"
 
 #define VIR_FROM_THIS VIR_FROM_LIBXL
 
@@ -456,6 +457,225 @@ libxlDomainMigrationPrepare(virConnectPtr dconn,
 return ret;
 }
 
+/* This function is a simplification of virDomainMigrateVersion3Full
+ * excluding tunnel support and restricting it to migration v3
+ * with params since it was the first to be introduced in libxl.
+ */
+static int
+libxlDoMigrateP2P(libxlDriverPrivatePtr driver,
+  virDomainObjPtr vm,
+  virConnectPtr sconn,
+  const char *xmlin,
+  virConnectPtr dconn,
+  const char *dconnuri ATTRIBUTE_UNUSED,
+  const char *dname,
+  const char *uri,
+  unsigned int flags)
+{
+virDomainPtr ddomain = NULL;
+virTypedParameterPtr params = NULL;
+int nparams = 0;
+int maxparams = 0;
+char *uri_out = NULL;
+char *dom_xml = NULL;
+unsigned long destflags;
+bool cancelled = true;
+virErrorPtr orig_err = NULL;
+int ret = -1;
+
+dom_xml = libxlDomainMigrationBegin(sconn, vm, xmlin);
+if (!dom_xml)
+goto cleanup;
+
+if (virTypedParamsAddString(, , ,
+VIR_MIGRATE_PARAM_DEST_XML, dom_xml) < 0)
+goto cleanup;
+
+if (dname &&
+virTypedParamsAddString(, , ,
+VIR_MIGRATE_PARAM_DEST_NAME, dname) < 0)
+goto cleanup;
+
+if (uri &&
+virTypedParamsAddString(, , ,
+VIR_MIGRATE_PARAM_URI, uri) < 0)
+goto cleanup;
+
+/* We don't require the destination to have P2P support
+ * as it looks to be normal migration from the receiver perpective.
+ */
+destflags = flags & ~(VIR_MIGRATE_PEER2PEER);
+
+VIR_DEBUG("Prepare3");
+virObjectUnlock(vm);
+ret = dconn->driver->domainMigratePrepare3Params
+(dconn, params, nparams, NULL, 0, NULL, NULL, _out, destflags);
+virObjectLock(vm);
+
+if (ret == -1)
+goto cleanup;
+
+if (uri_out) {
+if (virTypedParamsReplaceString(, ,
+VIR_MIGRATE_PARAM_URI, 

Re: [Xen-devel] [PATCH v8 18/21] libxc/xen: introduce a start info structure for HVMlite guests

2015-11-10 Thread Jan Beulich
>>> On 06.11.15 at 17:05,  wrote:
> --- a/xen/include/public/xen.h
> +++ b/xen/include/public/xen.h
> @@ -784,6 +784,29 @@ struct start_info {
>  };
>  typedef struct start_info start_info_t;
>  
> +/*
> + * Start of day structure passed to PVH guests in %ebx.
> + *
> + * NOTE: nothing will be loaded at physical address 0, so
> + * a 0 value in any of this fields should be treated as
> + * not present.
> + */
> +struct hvm_start_info {

Mind making the comment read "... in any of the address fields ..."?

Jan


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v2 4/7] xen: introduce XENPF_settime64

2015-11-10 Thread Arnd Bergmann
On Tuesday 10 November 2015 14:43:26 Stefano Stabellini wrote:
> On Tue, 10 Nov 2015, Arnd Bergmann wrote:
> > On Tuesday 10 November 2015 11:57:52 Stefano Stabellini wrote:
> > > Rename the current XENPF_settime hypercall and related struct to
> > > XENPF_settime32.
> > > 
> > > Signed-off-by: Stefano Stabellini 
> > > CC: konrad.w...@oracle.com
> > > CC: david.vra...@citrix.com
> > > CC: boris.ostrov...@oracle.com
> > 
> > Looks good.
> 
> Can I add your acked-by?
> 
> 

Yes, please do.

Arnd

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [linux-next test] 63942: tolerable FAIL

2015-11-10 Thread osstest service owner
flight 63942 linux-next real [real]
http://logs.test-lab.xenproject.org/osstest/logs/63942/

Failures :-/ but no regressions.

Regressions which are regarded as allowable (not blocking):
 test-amd64-i386-libvirt-xsm   6 xen-boot fail blocked in 63747
 test-amd64-i386-xl-qemuu-win7-amd64  6 xen-boot  fail blocked in 63747
 test-amd64-i386-xl-qemut-win7-amd64  6 xen-boot  fail blocked in 63747
 test-amd64-i386-libvirt   6 xen-boot fail blocked in 63747
 test-amd64-i386-rumpuserxen-i386  6 xen-boot fail blocked in 63747
 test-amd64-amd64-xl-qemuu-win7-amd64 17 guest-stop   fail blocked in 63747
 test-amd64-i386-libvirt-pair 10 xen-boot/dst_hostfail blocked in 63747
 test-amd64-i386-libvirt-pair  9 xen-boot/src_hostfail blocked in 63747
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm 6 xen-boot fail blocked in 
63747
 test-armhf-armhf-xl-rtds 15 guest-start.2fail blocked in 63747
 test-amd64-i386-xl-qemuu-debianhvm-amd64-xsm  6 xen-boot   fail like 63747
 test-amd64-i386-qemut-rhel6hvm-intel  6 xen-boot   fail like 63747
 test-amd64-i386-xl6 xen-boot fail   like 63747
 test-amd64-i386-xl-raw6 xen-boot fail   like 63747
 test-amd64-i386-freebsd10-i386  6 xen-boot fail like 63747
 test-amd64-i386-xl-qemuu-winxpsp3-vcpus1  6 xen-boot   fail like 63747
 test-amd64-i386-xl-qemut-winxpsp3-vcpus1  6 xen-boot   fail like 63747
 test-amd64-i386-xl-qemuu-debianhvm-amd64  6 xen-boot   fail like 63747
 test-amd64-i386-xl-qemuu-ovmf-amd64  6 xen-bootfail like 63747
 test-amd64-i386-xl-qemut-debianhvm-amd64-xsm  6 xen-boot   fail like 63747
 test-amd64-i386-xl-qemut-winxpsp3  6 xen-boot  fail like 63747
 test-amd64-i386-xl-xsm6 xen-boot fail   like 63747
 test-amd64-i386-xl-qemut-debianhvm-amd64  6 xen-boot   fail like 63747
 test-amd64-amd64-xl-qemut-stubdom-debianhvm-amd64-xsm 13 guest-localmigrate 
fail like 63747
 test-amd64-i386-qemut-rhel6hvm-amd  6 xen-boot fail like 63747
 test-amd64-i386-qemuu-rhel6hvm-amd  6 xen-boot fail like 63747
 test-amd64-i386-xl-qemut-stubdom-debianhvm-amd64-xsm 6 xen-boot fail like 63747
 test-amd64-i386-pair 10 xen-boot/dst_hostfail   like 63747
 test-amd64-i386-pair  9 xen-boot/src_hostfail   like 63747
 test-amd64-i386-qemuu-rhel6hvm-intel  6 xen-boot   fail like 63747
 test-amd64-i386-freebsd10-amd64  6 xen-bootfail like 63747
 test-amd64-i386-xl-qemuu-winxpsp3  6 xen-boot  fail like 63747

Tests which did not succeed, but are not blocking:
 test-armhf-armhf-xl-vhd   9 debian-di-installfail   never pass
 test-armhf-armhf-libvirt-raw  9 debian-di-installfail   never pass
 test-amd64-amd64-xl-pvh-amd  11 guest-start  fail   never pass
 test-armhf-armhf-libvirt 14 guest-saverestorefail   never pass
 test-armhf-armhf-libvirt 12 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt-xsm 12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-arndale  12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-arndale  13 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-xsm  13 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-xsm  12 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt 12 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt-vhd 11 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt-xsm 12 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt-xsm 14 guest-saverestorefail   never pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm 10 migrate-support-check 
fail never pass
 test-armhf-armhf-xl-multivcpu 13 saverestore-support-checkfail  never pass
 test-armhf-armhf-xl-multivcpu 12 migrate-support-checkfail  never pass
 test-armhf-armhf-xl  12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  13 saverestore-support-checkfail   never pass
 test-amd64-amd64-xl-qemut-win7-amd64 17 guest-stop fail never pass
 test-armhf-armhf-libvirt-qcow2  9 debian-di-installfail never pass
 test-armhf-armhf-xl-credit2  13 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-cubietruck 12 migrate-support-checkfail never pass
 test-armhf-armhf-xl-cubietruck 13 saverestore-support-checkfail never pass
 test-amd64-amd64-xl-pvh-intel 14 guest-saverestorefail  never pass
 test-armhf-armhf-xl-rtds 13 saverestore-support-checkfail   never pass
 

Re: [Xen-devel] [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64

2015-11-10 Thread Thomas Gleixner
On Tue, 10 Nov 2015, John Stultz wrote:
> I'm sort of objecting to a different issue, where the
> __current_kernel_time() implementation probably shouldn't be grabbing
> the tk_core.timekeeper directly, and instead should take a passed
> pointer to a timekeeper. The vdso/pv_clock usage should have a
> timekeeper passed to them that they could use.

That usage of __current_kernel_time() in that xen notifier is silly to
begin with. The notifier gets already called with a pointer to the
time keeper. That xen implementation just does not use it.

We extract exactly that information in the vdso updates without
calling back into the core code. So for solving that xen thing we do
not need a 64 bit variant of __current_kernel_time() at all. The
notifier has the pointer to the timekeeper and can just grab data from
there.

> There's one useage in kdb thats maybe problematic, so maybe this will
> need a deeper cleanup.

That one is silly as well. It only wants to know the seconds portion.

Thanks,

tglx

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH v2 5/8] xen: arm: add interfaces to save/restore the state of a PPI.

2015-11-10 Thread Ian Campbell
Make use of the GICD I[SC]ACTIVER registers to save and
restore the active state of the interrupt.

For edge triggered interrupts we also need to context switch the
pending bit via I[SC]PENDR. Note that for level triggered interrupts
SPENDR sets a latch which is only cleared by ICPENDR (and not by h/w
state changes), therefore we do not want to context switch the pending
state for level PPIs -- instead we rely on the context switch of the
peripheral to restore the correct level.

Tested on GIC v2 only.

Unused as yet, will be used by the vtimer code shortly.

Signed-off-by: Ian Campbell 
---
 xen/arch/arm/gic-v2.c| 67 
 xen/arch/arm/gic-v3.c| 67 
 xen/arch/arm/gic.c   | 54 +++
 xen/arch/arm/irq.c   |  7 +
 xen/include/asm-arm/domain.h | 11 
 xen/include/asm-arm/gic.h| 16 +++
 xen/include/asm-arm/irq.h|  3 ++
 7 files changed, 225 insertions(+)

diff --git a/xen/arch/arm/gic-v2.c b/xen/arch/arm/gic-v2.c
index 01e36b5..5308c35 100644
--- a/xen/arch/arm/gic-v2.c
+++ b/xen/arch/arm/gic-v2.c
@@ -81,6 +81,9 @@ static DEFINE_PER_CPU(u8, gic_cpu_id);
 /* Maximum cpu interface per GIC */
 #define NR_GIC_CPU_IF 8
 
+static void gicv2_irq_enable(struct irq_desc *desc);
+static void gicv2_irq_disable(struct irq_desc *desc);
+
 static inline void writeb_gicd(uint8_t val, unsigned int offset)
 {
 writeb_relaxed(val, gicv2.map_dbase + offset);
@@ -149,6 +152,37 @@ static void gicv2_save_state(struct vcpu *v)
 writel_gich(0, GICH_HCR);
 }
 
+static void gicv2_save_and_mask_hwppi(struct irq_desc *desc,
+  struct hwppi_state *s)
+{
+const unsigned int mask = (1u << desc->irq);
+const unsigned int pendingr = readl_gicd(GICD_ISPENDR);
+const unsigned int activer = readl_gicd(GICD_ISACTIVER);
+const unsigned int enabler = readl_gicd(GICD_ISENABLER);
+const bool is_edge = !!(desc->arch.type & DT_IRQ_TYPE_EDGE_BOTH);
+
+s->active = !!(activer & mask);
+s->enabled = !!(enabler & mask);
+s->pending = !!(pendingr & mask);
+
+/* Write a 1 to IC...R to clear the corresponding bit of state */
+if ( s->active )
+writel_gicd(mask, GICD_ICACTIVER);
+/*
+ * For an edge interrupt clear the pending state, for a level interrupt
+ * this clears the latch there is no need since saving the peripheral state
+ * (and/or restoring the next VCPU) will cause the correct action.
+ */
+if ( is_edge && s->pending )
+writel_gicd(mask, GICD_ICPENDR);
+
+if ( s->enabled )
+gicv2_irq_disable(desc);
+
+ASSERT(!(readl_gicd(GICD_ISACTIVER) & mask));
+ASSERT(!(readl_gicd(GICD_ISENABLER) & mask));
+}
+
 static void gicv2_restore_state(const struct vcpu *v)
 {
 int i;
@@ -161,6 +195,37 @@ static void gicv2_restore_state(const struct vcpu *v)
 writel_gich(GICH_HCR_EN, GICH_HCR);
 }
 
+static void gicv2_restore_hwppi(struct irq_desc *desc,
+const struct hwppi_state *s)
+{
+const unsigned int mask = (1u << desc->irq);
+const bool is_edge = !!(desc->arch.type & DT_IRQ_TYPE_EDGE_BOTH);
+
+/*
+ * The IRQ must always have been set inactive and masked etc by
+ * the saving of the previous state via save_and_mask_hwppi.
+ */
+ASSERT(!(readl_gicd(GICD_ISACTIVER) & mask));
+ASSERT(!(readl_gicd(GICD_ISENABLER) & mask));
+
+if ( s->active )
+writel_gicd(mask, GICD_ICACTIVER);
+
+/*
+ * Restore pending state for edge triggered interrupts only. For
+ * level triggered interrupts the level will be restored as
+ * necessary by restoring the state of the relevant peripheral.
+ *
+ * For a level triggered interrupt ISPENDR acts as a *latch* which
+ * is only cleared by ICPENDR (i.e. the input level is no longer
+ * relevant). We certainly do not want that here.
+ */
+if ( is_edge && s->pending )
+writel_gicd(mask, GICD_ISPENDR);
+if ( s->enabled )
+gicv2_irq_enable(desc);
+}
+
 static void gicv2_dump_state(const struct vcpu *v)
 {
 int i;
@@ -744,7 +809,9 @@ const static struct gic_hw_operations gicv2_ops = {
 .init= gicv2_init,
 .secondary_init  = gicv2_secondary_cpu_init,
 .save_state  = gicv2_save_state,
+.save_and_mask_hwppi = gicv2_save_and_mask_hwppi,
 .restore_state   = gicv2_restore_state,
+.restore_hwppi   = gicv2_restore_hwppi,
 .dump_state  = gicv2_dump_state,
 .gic_host_irq_type   = _host_irq_type,
 .gic_guest_irq_type  = _guest_irq_type,
diff --git a/xen/arch/arm/gic-v3.c b/xen/arch/arm/gic-v3.c
index 4fe0c37..cfe705a 100644
--- a/xen/arch/arm/gic-v3.c
+++ b/xen/arch/arm/gic-v3.c
@@ -61,6 +61,9 @@ static DEFINE_PER_CPU(void __iomem*, rbase);
 #define GICD_RDIST_BASE(this_cpu(rbase))
 #define 

[Xen-devel] [PATCH v2 2/8] xen: arm: fix typo in the description of struct pending_irq->desc

2015-11-10 Thread Ian Campbell
s/it/if/ makes more sense.

Signed-off-by: Ian Campbell 
---
 xen/include/asm-arm/vgic.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h
index cb51a9e..7d580cc 100644
--- a/xen/include/asm-arm/vgic.h
+++ b/xen/include/asm-arm/vgic.h
@@ -66,7 +66,7 @@ struct pending_irq
 #define GIC_IRQ_GUEST_ENABLED  3
 #define GIC_IRQ_GUEST_MIGRATING   4
 unsigned long status;
-struct irq_desc *desc; /* only set it the irq corresponds to a physical 
irq */
+struct irq_desc *desc; /* only set if the irq corresponds to a physical 
irq */
 unsigned int irq;
 #define GIC_INVALID_LR ~(uint8_t)0
 uint8_t lr;
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH v2 7/8] xen: arm: context switch vtimer PPI state.

2015-11-10 Thread Ian Campbell
... instead of artificially masking the timer interrupt in the timer
state and relying on the guest to unmask (which it isn't required to
do per the h/w spec, although Linux does).

By using the newly added hwppi save/restore functionality we make use
of the GICD I[SC]ACTIVER registers to save and restore the active
state of the interrupt, which prevents the nested invocations which
the current masking works around.

Signed-off-by: Ian Campbell 
---
v2: Rebased, in particular over Julien's passthrough stuff which
reworked a bunch of IRQ related stuff.
Also largely rewritten since precursor patches now lay very
different groundwork.
---
 xen/arch/arm/time.c  | 26 ++
 xen/arch/arm/vtimer.c| 41 +
 xen/include/asm-arm/domain.h |  1 +
 3 files changed, 40 insertions(+), 28 deletions(-)

diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c
index 5ded30c..2a1cdba 100644
--- a/xen/arch/arm/time.c
+++ b/xen/arch/arm/time.c
@@ -181,28 +181,6 @@ static void timer_interrupt(int irq, void *dev_id, struct 
cpu_user_regs *regs)
 }
 }
 
-static void vtimer_interrupt(int irq, void *dev_id, struct cpu_user_regs *regs)
-{
-/*
- * Edge-triggered interrupts can be used for the virtual timer. Even
- * if the timer output signal is masked in the context switch, the
- * GIC will keep track that of any interrupts raised while IRQS are
- * disabled. As soon as IRQs are re-enabled, the virtual interrupt
- * will be injected to Xen.
- *
- * If an IDLE vCPU was scheduled next then we should ignore the
- * interrupt.
- */
-if ( unlikely(is_idle_vcpu(current)) )
-return;
-
-perfc_incr(virt_timer_irqs);
-
-current->arch.virt_timer.ctl = READ_SYSREG32(CNTV_CTL_EL0);
-WRITE_SYSREG32(current->arch.virt_timer.ctl | CNTx_CTL_MASK, CNTV_CTL_EL0);
-vgic_vcpu_inject_irq(current, current->arch.virt_timer.irq);
-}
-
 /*
  * Arch timer interrupt really ought to be level triggered, since the
  * design of the timer/comparator mechanism is based around that
@@ -242,8 +220,8 @@ void __cpuinit init_timer_interrupt(void)
 
 request_irq(timer_irq[TIMER_HYP_PPI], 0, timer_interrupt,
 "hyptimer", NULL);
-request_irq(timer_irq[TIMER_VIRT_PPI], 0, vtimer_interrupt,
-   "virtimer", NULL);
+route_hwppi_to_current_vcpu(timer_irq[TIMER_VIRT_PPI], "virtimer");
+
 request_irq(timer_irq[TIMER_PHYS_NONSECURE_PPI], 0, timer_interrupt,
 "phytimer", NULL);
 
diff --git a/xen/arch/arm/vtimer.c b/xen/arch/arm/vtimer.c
index 1418092..82e2b88 100644
--- a/xen/arch/arm/vtimer.c
+++ b/xen/arch/arm/vtimer.c
@@ -55,9 +55,19 @@ static void phys_timer_expired(void *data)
 static void virt_timer_expired(void *data)
 {
 struct vtimer *t = data;
-t->ctl |= CNTx_CTL_MASK;
-vgic_vcpu_inject_irq(t->v, t->irq);
-perfc_incr(vtimer_virt_inject);
+t->ctl |= CNTx_CTL_PENDING;
+if ( !(t->ctl & CNTx_CTL_MASK) )
+{
+/*
+ * An edge triggered interrupt should now be pending. Since
+ * this timer can never expire while the domain is scheduled
+ * we know that the gic_restore_hwppi in virt_timer_restore
+ * will cause the real hwppi to occur and be routed.
+ */
+gic_hwppi_set_pending(>ppi_state);
+vcpu_unblock(t->v);
+perfc_incr(vtimer_virt_inject);
+}
 }
 
 int domain_vtimer_init(struct domain *d, struct xen_arch_domainconfig *config)
@@ -96,9 +106,12 @@ int domain_vtimer_init(struct domain *d, struct 
xen_arch_domainconfig *config)
 
 int vcpu_vtimer_init(struct vcpu *v)
 {
+struct pending_irq *p;
 struct vtimer *t = >arch.phys_timer;
 bool_t d0 = is_hardware_domain(v->domain);
 
+const unsigned host_vtimer_irq_ppi = timer_get_irq(TIMER_VIRT_PPI);
+
 /*
  * Hardware domain uses the hardware interrupts, guests get the virtual
  * platform.
@@ -116,10 +129,16 @@ int vcpu_vtimer_init(struct vcpu *v)
 init_timer(>timer, virt_timer_expired, t, v->processor);
 t->ctl = 0;
 t->irq = d0
-? timer_get_irq(TIMER_VIRT_PPI)
+? host_vtimer_irq_ppi
 : GUEST_TIMER_VIRT_PPI;
 t->v = v;
 
+p = irq_to_pending(v, t->irq);
+p->irq = t->irq;
+
+gic_hwppi_state_init(>arch.virt_timer.ppi_state,
+ host_vtimer_irq_ppi);
+
 v->arch.vtimer_initialized = 1;
 
 return 0;
@@ -147,6 +166,15 @@ int virt_timer_save(struct vcpu *v)
 set_timer(>arch.virt_timer.timer, 
ticks_to_ns(v->arch.virt_timer.cval +
   v->domain->arch.virt_timer_base.offset - boot_count));
 }
+
+/*
+ * Since the vtimer irq is a PPI we don't need to worry about
+ * racing against it becoming active while we are saving the
+ * state, since that requires the guest to be reading the IAR.
+ */
+gic_save_and_mask_hwppi(v, v->arch.virt_timer.irq,
+   

[Xen-devel] [PATCH v2] xen: arm: context switch vtimer PPI state.

2015-11-10 Thread Ian Campbell
... instead of artificially masking the timer interrupt in the timer
state and relying on the guest to unmask which it isn't required to
do per the h/w spec, although Linux does, other OSes (FreeRTOS?) needed
changes. Making the vtimer follow the h/w spec is the main driving force
here although it may also enable us to do direct injection in the future
(GIC >=v4). It's also something I wanted to sort out before starting to
think about how to migrate a vtimer.

This series introduces the concept of routing a PPI to the currently
running VCPU and of context switching its state using the GICD I[SC]ACTIVER
registers to save and restore the active state of the interrupt. In the
case of the vtimer this prevents the nested invocations which the current
masking works around.

For edge triggered interrupts we also need to context switch the
pending bit via I[SC]PENDR. Note that for level triggered interrupts
SPENDR sets a latch which is only cleared by ICPENDR (and not by h/w
state changes), therefore we do not want to context switch the pending
state for level PPIs -- instead we rely on the context switch of the
peripheral to restore the correct level.

This is an update of a much older RFC[0]. Lots has changed, the hooks are
now at a different level with more common code (although maybe not as much
as I would like) and lots of refactoring, It also now handles non-1:1
configurations (tested with a patch to force GUEST_TIMER_VIRT_PPI to
something whic didn't match the h/w platform).

I also switched from using struct irq_guest->d (domain) == NULL to signal
this type of interrupt to using desc->state containing both IRQ_GUEST and
IRQ_PER_CPU as the trigger instead as discussed in[1].

I think I've addressed all the comments which remained relevant after the
reworking, although so much has changed I'm not completely sure, sorry if
I've missed anything.

Ian.

[0] http://lists.xen.org/archives/html/xen-devel/2015-01/msg03161.html
[1] http://lists.xen.org/archives/html/xen-devel/2015-11/msg00842.html

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH v2 6/8] xen: arm: supporting routing a PPI to the current vcpu.

2015-11-10 Thread Ian Campbell
That is whichever vcpu is resident when the interrupt fires. An
interrupt is in this state when both IRQ_GUEST and IRQ_PER_CPU are set
in the descriptor status. Only PPIs can be in this mode.

This requires some peripheral specific code to make use of the
previously introduced functionality to save and restore the PPI state.
The vtimer driver will do so shortly.

Signed-off-by: Ian Campbell 
---
 xen/arch/arm/gic.c| 24 ++
 xen/arch/arm/irq.c| 84 +--
 xen/include/asm-arm/gic.h |  2 ++
 xen/include/asm-arm/irq.h |  2 +-
 4 files changed, 101 insertions(+), 11 deletions(-)

diff --git a/xen/arch/arm/gic.c b/xen/arch/arm/gic.c
index e294e89..aea913b 100644
--- a/xen/arch/arm/gic.c
+++ b/xen/arch/arm/gic.c
@@ -177,6 +177,30 @@ void gic_route_irq_to_xen(struct irq_desc *desc, const 
cpumask_t *cpu_mask,
 gic_set_irq_properties(desc, cpu_mask, priority);
 }
 
+/* Program the GIC to route an interrupt to the current guest
+ *
+ * That is the IRQ is delivered to whichever VCPU happens to be
+ * resident on the PCPU when the interrupt arrives.
+ *
+ * Currently the interrupt *must* be a PPI and the code responsible
+ * for the related hardware must save and restore the PPI with
+ * gic_save_and_mask_hwppi/gic_restore_hwppi.
+ */
+int gic_route_irq_to_current_guest(struct irq_desc *desc,
+   unsigned int priority)
+{
+ASSERT(spin_is_locked(>lock));
+ASSERT(desc->irq >= 16 && desc->irq < 32);
+
+desc->handler = gic_hw_ops->gic_guest_irq_type;
+set_bit(_IRQ_GUEST, >status);
+set_bit(_IRQ_PER_CPU, >status);
+
+gic_set_irq_properties(desc, cpumask_of(smp_processor_id()), GIC_PRI_IRQ);
+
+return 0;
+}
+
 /* Program the GIC to route an interrupt to a guest
  *   - desc.lock must be held
  */
diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
index 95be10e..ca18403 100644
--- a/xen/arch/arm/irq.c
+++ b/xen/arch/arm/irq.c
@@ -229,12 +229,15 @@ void do_IRQ(struct cpu_user_regs *regs, unsigned int irq, 
int is_fiq)
 set_bit(_IRQ_INPROGRESS, >status);
 
 /*
- * The irq cannot be a PPI, we only support delivery of SPIs to
- * guests.
+ * A PPI exposed to a guest must always be in IRQ_GUEST|IRQ_PER_CPU
+ * mode ("route to active VCPU"), so we use current.
+ *
+ * For SPI we look up the required target as normal.
  */
-v = vgic_get_target_vcpu(info->d->vcpu[0], info->virq);
-vgic_vcpu_inject_irq(v, info->virq);
+v = test_bit(_IRQ_PER_CPU, >status) ? current :
+vgic_get_target_vcpu(info->d->vcpu[0], info->virq);
 
+vgic_vcpu_inject_irq(v, info->virq);
 goto out_no_end;
 }
 
@@ -363,11 +366,15 @@ int setup_irq(unsigned int irq, unsigned int irqflags, 
struct irqaction *new)
 
 if ( test_bit(_IRQ_GUEST, >status) )
 {
-struct domain *d = irq_get_domain(desc);
+struct irq_guest *info = irq_get_guest_info(desc);
 
 spin_unlock_irqrestore(>lock, flags);
-printk(XENLOG_ERR "ERROR: IRQ %u is already in use by the domain %u\n",
-   irq, d->domain_id);
+if ( !test_bit(_IRQ_PER_CPU, >status) )
+printk(XENLOG_ERR "ERROR: IRQ %u is already in use by domain %u\n",
+   irq, info->d->domain_id);
+else
+printk(XENLOG_ERR
+   "ERROR: IRQ %u is already in use by \n", irq);
 return -EBUSY;
 }
 
@@ -410,7 +417,7 @@ static int setup_guest_irq(struct irq_desc *desc, unsigned 
int virq,
 {
 const unsigned irq = desc->irq;
 struct irqaction *action;
-int retval = 0;
+int retval;
 
 ASSERT(spin_is_locked(>lock));
 
@@ -451,12 +458,21 @@ static int setup_guest_irq(struct irq_desc *desc, 
unsigned int virq,
d->domain_id, irq, irq_get_guest_info(desc)->virq);
 retval = -EBUSY;
 }
+else
+retval = 0;
 goto out;
 }
 
 if ( test_bit(_IRQ_GUEST, >status) )
-printk(XENLOG_G_ERR "IRQ %u is already used by domain %u\n",
-   irq, ad->domain_id);
+{
+if ( !test_bit(_IRQ_PER_CPU, >status) )
+printk(XENLOG_ERR
+   "ERROR: IRQ %u is already used by domain %u\n",
+   irq, ad->domain_id);
+else
+printk(XENLOG_ERR
+   "ERROR: IRQ %u is already used by \n", 
irq);
+}
 else
 printk(XENLOG_G_ERR "IRQ %u is already used by Xen\n", irq);
 retval = -EBUSY;
@@ -542,6 +558,54 @@ free_info:
 return retval;
 }
 
+/*
+ * Route a PPI such that it is always delivered to the current vcpu on
+ * the pcpu. The driver for the peripheral must use
+ * gic_{save_and_mask,restore}_hwppi as part of the context switch.
+ */
+int route_hwppi_to_current_vcpu(unsigned 

[Xen-devel] [PATCH v2 3/8] xen: arm: Refactor route_irq_to_guest

2015-11-10 Thread Ian Campbell
Split out the bit which allocates the struct irqaction and calls
__setup_irq into a new function (setup_guest_irq). I'm going to want
to call this a second time in a subsequent patch.

Note that the action is now allocated and initialised with the desc
lock held (since it is taken by the caller). I don't think this is an
issue (and avoiding this would make things more complex)

Signed-off-by: Ian Campbell 
---
v2: New patch (maybe, it's been a while...)
---
 xen/arch/arm/irq.c | 104 +++--
 1 file changed, 61 insertions(+), 43 deletions(-)

diff --git a/xen/arch/arm/irq.c b/xen/arch/arm/irq.c
index 5031777..6918438 100644
--- a/xen/arch/arm/irq.c
+++ b/xen/arch/arm/irq.c
@@ -394,61 +394,24 @@ bool_t is_assignable_irq(unsigned int irq)
 return ((irq >= NR_LOCAL_IRQS) && (irq < gic_number_lines()));
 }
 
-/*
- * Route an IRQ to a specific guest.
- * For now only SPIs are assignable to the guest.
- */
-int route_irq_to_guest(struct domain *d, unsigned int virq,
-   unsigned int irq, const char * devname)
+static int setup_guest_irq(struct irq_desc *desc, unsigned int virq,
+   unsigned int irqflags,
+   struct irq_guest *info, const char *devname)
 {
+const unsigned irq = desc->irq;
 struct irqaction *action;
-struct irq_guest *info;
-struct irq_desc *desc;
-unsigned long flags;
 int retval = 0;
 
-if ( virq >= vgic_num_irqs(d) )
-{
-printk(XENLOG_G_ERR
-   "the vIRQ number %u is too high for domain %u (max = %u)\n",
-   irq, d->domain_id, vgic_num_irqs(d));
-return -EINVAL;
-}
-
-/* Only routing to virtual SPIs is supported */
-if ( virq < NR_LOCAL_IRQS )
-{
-printk(XENLOG_G_ERR "IRQ can only be routed to an SPI\n");
-return -EINVAL;
-}
-
-if ( !is_assignable_irq(irq) )
-{
-printk(XENLOG_G_ERR "the IRQ%u is not routable\n", irq);
-return -EINVAL;
-}
-desc = irq_to_desc(irq);
+ASSERT(spin_is_locked(>lock));
 
 action = xmalloc(struct irqaction);
 if ( !action )
 return -ENOMEM;
 
-info = xmalloc(struct irq_guest);
-if ( !info )
-{
-xfree(action);
-return -ENOMEM;
-}
-
-info->d = d;
-info->virq = virq;
-
 action->dev_id = info;
 action->name = devname;
 action->free_on_release = 1;
 
-spin_lock_irqsave(>lock, flags);
-
 if ( desc->arch.type == DT_IRQ_TYPE_INVALID )
 {
 printk(XENLOG_G_ERR "IRQ %u has not been configured\n", irq);
@@ -466,6 +429,7 @@ int route_irq_to_guest(struct domain *d, unsigned int virq,
  */
 if ( desc->action != NULL )
 {
+struct domain *d = info->d;
 struct domain *ad = irq_get_domain(desc);
 
 if ( test_bit(_IRQ_GUEST, >status) && d == ad )
@@ -493,6 +457,61 @@ int route_irq_to_guest(struct domain *d, unsigned int virq,
 if ( retval )
 goto out;
 
+return 0;
+
+out:
+xfree(action);
+return retval;
+}
+
+/*
+ * Route an IRQ to a specific guest.
+ * For now only SPIs are assignable to the guest.
+ */
+int route_irq_to_guest(struct domain *d, unsigned int virq,
+   unsigned int irq, const char * devname)
+{
+struct irq_guest *info;
+struct irq_desc *desc;
+unsigned long flags;
+int retval;
+
+if ( virq >= vgic_num_irqs(d) )
+{
+printk(XENLOG_G_ERR
+   "the vIRQ number %u is too high for domain %u (max = %u)\n",
+   irq, d->domain_id, vgic_num_irqs(d));
+return -EINVAL;
+}
+
+/* Only routing to virtual SPIs is supported */
+if ( virq < NR_LOCAL_IRQS )
+{
+printk(XENLOG_G_ERR "IRQ can only be routed to an SPI\n");
+return -EINVAL;
+}
+
+if ( !is_assignable_irq(irq) )
+{
+printk(XENLOG_G_ERR "the IRQ%u is not routable\n", irq);
+return -EINVAL;
+}
+
+desc = irq_to_desc(irq);
+
+info = xmalloc(struct irq_guest);
+if ( !info )
+return -ENOMEM;
+
+info->d = d;
+info->virq = virq;
+
+spin_lock_irqsave(>lock, flags);
+
+retval = setup_guest_irq(desc, virq, flags, info, devname);
+if ( retval )
+goto out;
+
 retval = gic_route_irq_to_guest(d, virq, desc, GIC_PRI_IRQ);
 
 spin_unlock_irqrestore(>lock, flags);
@@ -507,7 +526,6 @@ int route_irq_to_guest(struct domain *d, unsigned int virq,
 
 out:
 spin_unlock_irqrestore(>lock, flags);
-xfree(action);
 free_info:
 xfree(info);
 
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [RFC PATCH v2 01/16] hvmloader: Fix scratch_alloc to avoid overlaps

2015-11-10 Thread Jan Beulich
>>> On 26.10.15 at 17:03,  wrote:
> --- a/tools/firmware/hvmloader/util.c
> +++ b/tools/firmware/hvmloader/util.c
> @@ -479,7 +479,7 @@ void *scratch_alloc(uint32_t size, uint32_t align)
>  align = 16;
>  
>  s = (scratch_start + align - 1) & ~(align - 1);
> -e = s + size - 1;
> +e = s + size;

This further increases the delta to the actually quite similar
mem_alloc(). I'd prefer the two to remain in sync as much as
possible, and hence either the other one to also be adjusted
or this one to be fixed the other way around (dropping the
first "- 1" in the assignment to s, but requiring changes
elsewhere too).

Jan


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v2 2/3] XENVER_build_id: Provide ld-embedded build-ids

2015-11-10 Thread Jan Beulich
>>> On 06.11.15 at 20:36,  wrote:
> --- a/xen/arch/x86/Makefile
> +++ b/xen/arch/x86/Makefile
> @@ -109,15 +109,19 @@ $(TARGET)-syms: prelink.o xen.lds 
> $(BASEDIR)/common/symbols-dummy.o
>   $(NM) -pa --format=sysv $(@D)/.$(@F).0 \
>   | $(BASEDIR)/tools/symbols --sysv --sort >$(@D)/.$(@F).0.S
>   $(MAKE) -f $(BASEDIR)/Rules.mk $(@D)/.$(@F).0.o
> - $(LD) $(LDFLAGS) -T xen.lds -N prelink.o \
> + $(LD) $(LDFLAGS) -T xen.lds -N prelink.o --build-id=sha1 \

You continue to use option this unconditionally.

Jan


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v9 15/17] vmx: VT-d posted-interrupt core logic handling

2015-11-10 Thread Dario Faggioli
On Tue, 2015-11-03 at 09:07 +, Wu, Feng wrote:
> BTW, In the previous discussion, we will do the PI state adjustment
> in vmx_do_resume, however, seems this is not a good place to do this,
> since this function gets called only if the scheduling occurs, no
> matter it switches to another vCPU or continue runs the current vCPU.
> If no scheduling happens during "VM->Xen->VM", vmx-do_resume() will
> not get called. 
>
Mmm... When I first read this, it seemed to me to be a good thing, and
a reason for actually putting your logic in there (that would avoid
paying the price of going through it during every VMENTRY, which you
were yourself hesitant about)!

So, maybe I'm missing/misremembering something. Just to be sure, can
you tell me...

> So I put the PI state adjustment code in vmx_vmenter_helper(), if you
> have any other good suggestions, please let me know, thanks a lot!
> 
... what is the reason(s) why you need to do the update even if no
scheduling happened?

Looking at the code again, I think one reason may be to cope with when
vcpu_block() is called, but then local_events_need_delivery() returns
true, as shown here below:

void vcpu_block(void)
{
struct vcpu *v = current;

set_bit(_VPF_blocked, >pause_flags);

arch_vcpu_block(v); // nv <--- pi_wakeup_vector

/* Check for events /after/ blocking: avoids wakeup waiting race. */
if ( local_events_need_delivery() ) // <=== TRUE
clear_bit(_VPF_blocked, >pause_flags);
// we want nv == 
posted_intr_vector,
   so we need 
vmx_pi_state_change()
   to run, even if we're 
not scheduling
}

Is this the case?

Regards,
Dario

-- 
<> (Raistlin Majere)
-
Dario Faggioli, Ph.D, http://about.me/dario.faggioli
Senior Software Engineer, Citrix Systems R Ltd., Cambridge (UK)



signature.asc
Description: This is a digitally signed message part
___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH 4/4] x86/traps: honor EXT bit in error codes

2015-11-10 Thread Jan Beulich
The specification does not explicitly limit the use of this bit to
exceptions that can have selector style error codes, so to be on the
safe side we should deal with it being set even on error codes formally
documented to be always zero (if they're indeed always zero, the change
is simply dead code in those cases).

Introduce and use (where suitable) X86_XEC_* constants to make the code
easier to read.

To match the placement of the "hardware_trap" lable, the "hardware_gp"
one gets moved slightly too.

Signed-off-by: Jan Beulich 

--- a/xen/arch/x86/cpu/mcheck/mce.c
+++ b/xen/arch/x86/cpu/mcheck/mce.c
@@ -431,16 +431,16 @@ static enum mce_result mce_action(const
 
 /*
  * Return:
- * -1: if system can't be recovered
+ * 1: if system can't be recovered
  * 0: Continue to next step
  */
-static int mce_urgent_action(const struct cpu_user_regs *regs,
-  mctelem_cookie_t mctc)
+static bool_t mce_urgent_action(const struct cpu_user_regs *regs,
+mctelem_cookie_t mctc)
 {
 uint64_t gstatus;
 
-if ( mctc == NULL)
-return 0;
+if ( regs->error_code & X86_XEC_EXT )
+return 1;
 
 gstatus = mca_rdmsr(MSR_IA32_MCG_STATUS);
 
@@ -455,9 +455,9 @@ static int mce_urgent_action(const struc
  */
 if ( !(gstatus & MCG_STATUS_RIPV) &&
  (!(gstatus & MCG_STATUS_EIPV) || !guest_mode(regs)) )
-return -1;
+return 1;
 
-return mce_action(regs, mctc) == MCER_RESET ? -1 : 0;
+return mctc && mce_action(regs, mctc) == MCER_RESET;
 }
 
 /* Shared #MC handler. */
--- a/xen/arch/x86/traps.c
+++ b/xen/arch/x86/traps.c
@@ -618,6 +618,9 @@ static void do_trap(struct cpu_user_regs
 unsigned int trapnr = regs->entry_vector;
 unsigned long fixup;
 
+if ( use_error_code && (regs->error_code & X86_XEC_EXT) )
+goto hardware_trap;
+
 DEBUGGER_trap_entry(trapnr, regs);
 
 if ( guest_mode(regs) )
@@ -644,6 +647,7 @@ static void do_trap(struct cpu_user_regs
 return;
 }
 
+ hardware_trap:
 DEBUGGER_trap_fatal(trapnr, regs);
 
 show_execution_state(regs);
@@ -1265,13 +1269,14 @@ static int handle_gdt_ldt_mapping_fault(
 tb = propagate_page_fault(curr->arch.pv_vcpu.ldt_base + offset,
   regs->error_code);
 if ( tb )
-tb->error_code = ((u16)offset & ~3) | 4;
+tb->error_code = (offset & ~(X86_XEC_EXT | X86_XEC_IDT)) |
+ X86_XEC_TI;
 }
 }
 else
 {
 /* GDT fault: handle the fault as #GP(selector). */
-regs->error_code = (u16)offset & ~7;
+regs->error_code = offset & ~(X86_XEC_EXT | X86_XEC_IDT | X86_XEC_TI);
 (void)do_general_protection(regs);
 }
 
@@ -3231,7 +3236,7 @@ void do_general_protection(struct cpu_us
 
 DEBUGGER_trap_entry(TRAP_gp_fault, regs);
 
-if ( regs->error_code & 1 )
+if ( regs->error_code & X86_XEC_EXT )
 goto hardware_gp;
 
 if ( !guest_mode(regs) )
@@ -3257,7 +3262,7 @@ void do_general_protection(struct cpu_us
  * instruction. The DPL specified by the guest OS for these vectors is NOT
  * CHECKED!!
  */
-if ( (regs->error_code & 3) == 2 )
+if ( regs->error_code & X86_XEC_IDT )
 {
 /* This fault must be due to  instruction. */
 const struct trap_info *ti;
@@ -3299,9 +3304,9 @@ void do_general_protection(struct cpu_us
 return;
 }
 
+ hardware_gp:
 DEBUGGER_trap_fatal(TRAP_gp_fault, regs);
 
- hardware_gp:
 show_execution_state(regs);
 panic("GENERAL PROTECTION FAULT\n[error_code=%04x]", regs->error_code);
 }
--- a/xen/arch/x86/x86_64/entry.S
+++ b/xen/arch/x86/x86_64/entry.S
@@ -338,7 +338,7 @@ int80_slow_path:
  * Setup entry vector and error code as if this was a GPF caused by an
  * IDT entry with DPL==0.
  */
-movl  $((0x80 << 3) | 0x2),UREGS_error_code(%rsp)
+movl  $((0x80 << 3) | X86_XEC_IDT),UREGS_error_code(%rsp)
 SAVE_PRESERVED
 movl  $TRAP_gp_fault,UREGS_entry_vector(%rsp)
 /* A GPF wouldn't have incremented the instruction pointer. */
--- a/xen/include/asm-x86/processor.h
+++ b/xen/include/asm-x86/processor.h
@@ -143,6 +143,11 @@
 #define PFEC_page_paged (1U<<5)
 #define PFEC_page_shared(1U<<6)
 
+/* Other exception error code values. */
+#define X86_XEC_EXT (_AC(1,U) << 0)
+#define X86_XEC_IDT (_AC(1,U) << 1)
+#define X86_XEC_TI  (_AC(1,U) << 2)
+
 #define XEN_MINIMAL_CR4 (X86_CR4_PGE | X86_CR4_PAE)
 
 #define XEN_SYSCALL_MASK (X86_EFLAGS_AC|X86_EFLAGS_VM|X86_EFLAGS_RF|\


x86/traps: honor EXT bit in error codes

The specification does not explicitly limit the use of this bit to
exceptions that can have selector style error codes, so to be on the
safe side we should deal with it being set even on error codes formally
documented to be always zero (if they're indeed always 

Re: [Xen-devel] [PATCH 2/4] x86/HVM: unify and fix #UD intercept

2015-11-10 Thread Andrew Cooper
On 10/11/15 17:39, Jan Beulich wrote:
> The SVM and VMX versions really were identical, so instead of fixing
> the same issue in two places, fold them at once. The issue fixed is the
> missing seg:off -> linear translation of the current code address.
>
> Signed-off-by: Jan Beulich 

Reviewed-by: Andrew Cooper 

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH] xen/gntdev: Grant maps should not be subject to NUMA balancing

2015-11-10 Thread Boris Ostrovsky
Doing so will cause the grant to be unmapped and then, during
fault handling, the fault to be mistakenly treated as NUMA hint
fault.

In addition, even if we those maps could partcipate in NUMA
balancing it wouldn't provide any benefit since we wouldn't be
able to determine physical page's node (even if/when VNUMA is
implemented).

Marking grant maps' VMAs as VM_IO will exclude them from being
part of NUMA balancing.

Signed-off-by: Boris Ostrovsky 
---
 drivers/xen/gntdev.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index 67b9163..bf312df 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -802,7 +802,7 @@ static int gntdev_mmap(struct file *flip, struct 
vm_area_struct *vma)
 
vma->vm_ops = _vmops;
 
-   vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
+   vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP | VM_IO;
 
if (use_ptemod)
vma->vm_flags |= VM_DONTCOPY;
-- 
1.7.1


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH 0/4] x86: XSA-156 follow-ups

2015-11-10 Thread Jan Beulich
Not much interrelation between them other than all having been
noticed while looking into the various aspects of XSA-156 (including
the investigations regarding possible further similar exploit
mechanisms).

1: x86/HVM: don't inject #DB with error code
2: x86/HVM: unify and fix #UD intercept
3: x86/SVM: don't exceed segment limit when fetching instruction bytes
4: x86/traps: honor EXT bit in error codes

Signed-off-by: Jan Beulich 


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [xen-4.3-testing test] 63948: regressions - FAIL

2015-11-10 Thread osstest service owner
flight 63948 xen-4.3-testing real [real]
http://logs.test-lab.xenproject.org/osstest/logs/63948/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-amd64-amd64-migrupgrade 21 guest-migrate/src_host/dst_host fail REGR. vs. 
63212

Regressions which are regarded as allowable (not blocking):
 test-amd64-amd64-xl-qemuu-win7-amd64 17 guest-stop fail like 63212

Tests which did not succeed, but are not blocking:
 test-amd64-amd64-rumpuserxen-amd64  1 build-check(1)   blocked n/a
 test-amd64-i386-rumpuserxen-i386  1 build-check(1)   blocked  n/a
 test-amd64-amd64-xl-qemuu-ovmf-amd64  9 debian-hvm-install fail never pass
 build-i386-rumpuserxen6 xen-buildfail   never pass
 build-amd64-rumpuserxen   6 xen-buildfail   never pass
 test-amd64-i386-migrupgrade 21 guest-migrate/src_host/dst_host fail never pass
 test-armhf-armhf-libvirt-qcow2  6 xen-boot fail never pass
 test-armhf-armhf-xl-arndale   6 xen-boot fail   never pass
 test-armhf-armhf-libvirt  6 xen-boot fail   never pass
 test-amd64-i386-xl-qemuu-ovmf-amd64  9 debian-hvm-install  fail never pass
 test-amd64-i386-libvirt  12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-credit2   6 xen-boot fail   never pass
 test-armhf-armhf-libvirt-raw  6 xen-boot fail   never pass
 test-amd64-i386-xl-qemut-win7-amd64 17 guest-stop  fail never pass
 test-amd64-amd64-libvirt-vhd 11 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-multivcpu  6 xen-boot fail  never pass
 test-armhf-armhf-xl-cubietruck  6 xen-boot fail never pass
 test-amd64-amd64-xl-qemut-win7-amd64 17 guest-stop fail never pass
 test-armhf-armhf-xl-vhd   6 xen-boot fail   never pass
 test-amd64-amd64-libvirt 12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl   6 xen-boot fail   never pass
 test-amd64-i386-xl-qemuu-win7-amd64 17 guest-stop  fail never pass
 test-amd64-i386-xend-qemut-winxpsp3 21 leak-check/checkfail never pass

version targeted for testing:
 xen  e875e0e5fcc5912f71422b53674a97e5c0ae77be
baseline version:
 xen  85ca813ec23c5a60680e4a13777dad530065902b

Last test of basis63212  2015-10-22 10:03:01 Z   19 days
Failing since 63360  2015-10-29 13:39:04 Z   12 days9 attempts
Testing same since63381  2015-10-30 18:44:54 Z   10 days8 attempts


People who touched revisions under test:
  Andrew Cooper 
  Ian Campbell 
  Ian Jackson 
  Jan Beulich 

jobs:
 build-amd64  pass
 build-armhf  pass
 build-i386   pass
 build-amd64-libvirt  pass
 build-armhf-libvirt  pass
 build-i386-libvirt   pass
 build-amd64-prev pass
 build-i386-prev  pass
 build-amd64-pvopspass
 build-armhf-pvopspass
 build-i386-pvops pass
 build-amd64-rumpuserxen  fail
 build-i386-rumpuserxen   fail
 test-amd64-amd64-xl  pass
 test-armhf-armhf-xl  fail
 test-amd64-i386-xl   pass
 test-amd64-i386-qemut-rhel6hvm-amd   pass
 test-amd64-i386-qemuu-rhel6hvm-amd   pass
 test-amd64-amd64-xl-qemut-debianhvm-amd64pass
 test-amd64-i386-xl-qemut-debianhvm-amd64 pass
 test-amd64-amd64-xl-qemuu-debianhvm-amd64pass
 test-amd64-i386-xl-qemuu-debianhvm-amd64 pass
 test-amd64-i386-freebsd10-amd64  pass
 test-amd64-amd64-xl-qemuu-ovmf-amd64 fail
 test-amd64-i386-xl-qemuu-ovmf-amd64  fail
 test-amd64-amd64-rumpuserxen-amd64   blocked
 test-amd64-amd64-xl-qemut-win7-amd64 fail
 test-amd64-i386-xl-qemut-win7-amd64  fail
 test-amd64-amd64-xl-qemuu-win7-amd64 fail
 test-amd64-i386-xl-qemuu-win7-amd64  fail
 

[Xen-devel] [PATCH 3/4] x86/SVM: don't exceed segment limit when fetching instruction bytes

2015-11-10 Thread Jan Beulich
Also consistently use the vmcb local variable whenever possible.

Signed-off-by: Jan Beulich 

--- a/xen/arch/x86/hvm/svm/emulate.c
+++ b/xen/arch/x86/hvm/svm/emulate.c
@@ -47,12 +47,17 @@ static unsigned int is_prefix(u8 opc)
 return 0;
 }
 
-static unsigned long svm_rip2pointer(struct vcpu *v)
+static unsigned long svm_rip2pointer(struct vcpu *v, unsigned long *limit)
 {
 struct vmcb_struct *vmcb = v->arch.hvm_svm.vmcb;
-unsigned long p = vmcb->cs.base + guest_cpu_user_regs()->eip;
+unsigned long p = vmcb->cs.base + vmcb->rip;
+
 if ( !(vmcb->cs.attr.fields.l && hvm_long_mode_enabled(v)) )
+{
+*limit = vmcb->cs.limit;
 return (u32)p; /* mask to 32 bits */
+}
+*limit = ~0UL;
 return p;
 }
 
@@ -125,11 +130,10 @@ static const u8 *const opc_bytes[INSTR_M
 [INSTR_INVLPGA] = OPCODE_INVLPGA,
 };
 
-static int fetch(struct vcpu *v, u8 *buf, unsigned long addr, int len)
+static bool_t fetch(const struct vmcb_struct *vmcb, u8 *buf,
+   unsigned long addr, unsigned int len)
 {
-uint32_t pfec;
-
-pfec = (vmcb_get_cpl(v->arch.hvm_svm.vmcb) == 3) ? PFEC_user_mode : 0;
+uint32_t pfec = (vmcb_get_cpl(vmcb) == 3) ? PFEC_user_mode : 0;
 
 switch ( hvm_fetch_from_guest_virt(buf, addr, len, pfec) )
 {
@@ -141,7 +145,7 @@ static int fetch(struct vcpu *v, u8 *buf
 default:
 /* Not OK: fetches from non-RAM pages are not supportable. */
 gdprintk(XENLOG_WARNING, "Bad instruction fetch at %#lx (%#lx)\n",
- (unsigned long) guest_cpu_user_regs()->eip, addr);
+ vmcb->rip, addr);
 hvm_inject_hw_exception(TRAP_gp_fault, 0);
 return 0;
 }
@@ -156,8 +160,8 @@ int __get_instruction_length_from_list(s
 enum instruction_index instr = 0;
 u8 buf[MAX_INST_LEN];
 const u8 *opcode = NULL;
-unsigned long fetch_addr;
-unsigned int fetch_len;
+unsigned long fetch_addr, fetch_limit;
+unsigned int fetch_len, max_len;
 
 if ( (inst_len = svm_nextrip_insn_length(v)) != 0 )
 return inst_len;
@@ -167,21 +171,24 @@ int __get_instruction_length_from_list(s
 
 /* Fetch up to the next page break; we'll fetch from the next page
  * later if we have to. */
-fetch_addr = svm_rip2pointer(v);
-fetch_len = min_t(unsigned int, MAX_INST_LEN,
+fetch_addr = svm_rip2pointer(v, _limit);
+if ( vmcb->rip > fetch_limit )
+return 0;
+max_len = min(fetch_limit - vmcb->rip + 1, MAX_INST_LEN + 0UL);
+fetch_len = min_t(unsigned int, max_len,
   PAGE_SIZE - (fetch_addr & ~PAGE_MASK));
-if ( !fetch(v, buf, fetch_addr, fetch_len) )
+if ( !fetch(vmcb, buf, fetch_addr, fetch_len) )
 return 0;
 
-while ( (inst_len < MAX_INST_LEN) && is_prefix(buf[inst_len]) )
+while ( (inst_len < max_len) && is_prefix(buf[inst_len]) )
 {
 inst_len++;
 if ( inst_len >= fetch_len )
 {
-if ( !fetch(v, buf + fetch_len, fetch_addr + fetch_len,
-MAX_INST_LEN - fetch_len) )
+if ( !fetch(vmcb, buf + fetch_len, fetch_addr + fetch_len,
+max_len - fetch_len) )
 return 0;
-fetch_len = MAX_INST_LEN;
+fetch_len = max_len;
 }
 }
 
@@ -190,15 +197,14 @@ int __get_instruction_length_from_list(s
 instr = list[j];
 opcode = opc_bytes[instr];
 
-for ( i = 0; (i < opcode[0]) && ((inst_len + i) < MAX_INST_LEN); i++ )
+for ( i = 0; (i < opcode[0]) && ((inst_len + i) < max_len); i++ )
 {
 if ( (inst_len + i) >= fetch_len ) 
-{ 
-if ( !fetch(v, buf + fetch_len, 
-fetch_addr + fetch_len, 
-MAX_INST_LEN - fetch_len) ) 
+{
+if ( !fetch(vmcb, buf + fetch_len, fetch_addr + fetch_len,
+max_len - fetch_len) )
 return 0;
-fetch_len = MAX_INST_LEN;
+fetch_len = max_len;
 }
 
 if ( buf[inst_len+i] != opcode[i+1] )
@@ -216,7 +222,7 @@ int __get_instruction_length_from_list(s
 
  done:
 inst_len += opcode[0];
-ASSERT(inst_len <= MAX_INST_LEN);
+ASSERT(inst_len <= max_len);
 return inst_len;
 }
 
--- a/xen/include/asm-x86/hvm/svm/vmcb.h
+++ b/xen/include/asm-x86/hvm/svm/vmcb.h
@@ -551,7 +551,7 @@ static inline void vmcb_set_##_name(stru
 vmcb->_##_name = value; \
 vmcb->cleanbits.fields._cleanbit = 0;   \
 }   \
-static inline _type vmcb_get_##_name(struct vmcb_struct *vmcb)  \
+static inline _type vmcb_get_##_name(const struct vmcb_struct *vmcb)\
 {   \
   

Re: [Xen-devel] [PATCH 3/4] x86/SVM: don't exceed segment limit when fetching instruction bytes

2015-11-10 Thread Boris Ostrovsky

On 11/10/2015 12:40 PM, Jan Beulich wrote:

Also consistently use the vmcb local variable whenever possible.

Signed-off-by: Jan Beulich 

--- a/xen/arch/x86/hvm/svm/emulate.c
+++ b/xen/arch/x86/hvm/svm/emulate.c


Reviewed-by: Boris Ostrovsky 



___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH V8 3/7] libxl: add pvusb API

2015-11-10 Thread George Dunlap
On Tue, Nov 10, 2015 at 8:41 AM, Chun Yan Liu  wrote:
>> > +void libxl__device_usbctrl_add(libxl__egc *egc, uint32_t domid,
>> > +   libxl_device_usbctrl *usbctrl,
>> > +   libxl__ao_device *aodev)
>> > +{
>>
>> Thanks for adjusting the error-handling patterns in these functions.
>> The new way is good, except that:
>>
>> > +out:
>> > +aodev->rc = rc;
>> > +if (rc) aodev->callback(egc, aodev);
>>
>> Here, rc is always set, and indeed the code would be wrong if it were
>> not.  So can you remove the conditional please ?  Ie:
>
> Reading the codes, libxl__wait_device_connection will call aodev->callback
> properly. So here, only if (rc != 0), that means error happens, then we need 
> to
> call aodev->callback to end the process. (Refer to current 
> libxl__device_disk_add,
> all current code does similar work.) So I think the code is not wrong (?)

>> > +static int usb_busaddr_from_busid(libxl__gc *gc, const char *busid,
>> > +  uint8_t *bus, uint8_t *addr)
>> > +{
>> > +char *filename;
>> > +void *buf;
>> > +
>> > +filename = GCSPRINTF(SYSFS_USB_DEV"/%s/busnum", busid);
>> > +if (!libxl__read_sysfs_file_contents(gc, filename, , NULL))
>> > +*bus = atoi((char *)buf);
>>
>> I don't think this cast (and the one for addr) are necessary ?
>
> Which cast? Here, we want to get a uint_8 value, but buf is a string,
> we need to do atoi.

atoi() isn't a cast, it's a function call.  The cast is the (char *) bit.

I think probably you could get away with declaring buf as (char *).
 should be converted to void** automatically without any warnings,
I think.

>> > +/* Encode usb interface so that it could be written to xenstore as a key.
>> > + *
>> > + * Since xenstore key cannot include '.' or ':', we'll change '.' to '_',
>> > + * change ':' to '-'. For example, 3-1:2.1 will be encoded to 3-1-2_1.
>> > + * This will be used to save original driver of USB device to xenstore.
>> > + */
>>
>> What is the syntax of the incoming busid ?  Could it contain _ or - ?
>> You should perhaps spot them and reject if it does.
>
> The busid is in syntax like 3-1:2.1. It does contain '-'. But since we only 
> use
> the single direction, never decode back, so it won't harm.

So the only potential problem is that 3-1:2, 3-1-2, 3:1-2, and 3:1:2
all collapse down to 3-1-2.  Is there any risk of something like that
happening?  (Ian: NB these are all read from sysfs.)

Since this isn't really being read by anyone,  maybe it would be
better to replace ':' with another character, just to be safe.  It
could even be something like 'c' if no other punctuation is available.

>> > +/* Bind USB device to "usbback" driver.
>> > + *
>> > + * If there are many interfaces under USB device, check each interface,
>> > + * unbind from original driver and bind to "usbback" driver.
>> > + */
>> > +static int usbback_dev_assign(libxl__gc *gc, libxl_device_usb *usb)
>> > +{
>> ...
>> > +if (libxl__xs_write_checked(gc, XBT_NULL, path, drvpath) < 0) 
>> > {
>> > +LOG(WARN, "Write of %s to node %s failed", drvpath, path);
>> > +}
>>
>> One of the advantages of libxl__xs_write_checked is that it logs
>> errors.  So you can leave that log message out.
>>
>> However, if the xs write fails, you should presumably stop, rather
>> than carrying on.
>>
>> I think you probably do things in the wrong order here.  You should
>> write the old driver info to xenstore first, so that if the bind to
>> usbback fails, you have the old driver info.

Ian, I don't understand what you're saying here.  The code I'm looking at does:
1. unbind + get old driver path in drvpath
2. if(drvpath) write to xenstore
3. bind to usbback

If the bind fails, then we do have drvpath in xenstore.  Or am I
missing something?

Bailing out if the above xenstore write fails seems sensible though.

>> > +/* Operation to remove usb device.
>> > + *
>> > + * Generally, it does:
>> > + * 1) check if the usb device is assigned to the domain
>> > + * 2) remove the usb device from xenstore controller/port.
>> > + * 3) unbind usb device from usbback and rebind to its original driver.
>> > + *If usb device has many interfaces, do it to each interface.
>> > + */
>> > +static int libxl__device_usb_remove(libxl__gc *gc, uint32_t domid,
>> > +libxl_device_usb *usb)
>> > +{
>> > +int rc;
>> > +
>> > +if (usb->ctrl < 0 || usb->port < 1) {
>> > +LOG(ERROR, "Invalid USB device");
>> > +rc = ERROR_FAIL;
>> > +goto out;
>> > +}
>> > +
>> > +if (usb->devtype == LIBXL_USBDEV_TYPE_HOSTDEV &&
>> > +(usb->u.hostdev.hostbus < 1 || usb->u.hostdev.hostaddr < 1)) {
>> > +LOG(ERROR, "Invalid USB device of hostdev");
>> > +rc = ERROR_FAIL;
>> > +goto out;
>> > +}
>>
>> Why are these checks here rather than in do_usb_remove ?
>>
>> For that 

[Xen-devel] Updated Xen Contributor Training

2015-11-10 Thread Lars Kurth
I Updated XP Contributor Training - Pt 2 Processes and Conventions v1.1.pdf and 
had to split it into two files due to the file size

See http://wiki.xenproject.org/wiki/Contributor_Training, 
http://www.slideshare.net/xen_com_mgr/xenprojectcontributortrainingpart2processesandconventionsv11-2
 and a few other pages linking to these

Regards
Lars
___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH 1/4] x86/HVM: don't inject #DB with error code

2015-11-10 Thread Jan Beulich
Signed-off-by: Jan Beulich 

--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -4133,7 +4133,7 @@ void hvm_task_switch(
 goto out;
 
 if ( (tss.trace & 1) && !exn_raised )
-hvm_inject_hw_exception(TRAP_debug, tss_sel & 0xfff8);
+hvm_inject_hw_exception(TRAP_debug, HVM_DELIVER_NO_ERROR_CODE);
 
 tr.attr.fields.type = 0xb; /* busy 32-bit tss */
 hvm_set_segment_register(v, x86_seg_tr, );



x86/HVM: don't inject #DB with error code

Signed-off-by: Jan Beulich 

--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -4133,7 +4133,7 @@ void hvm_task_switch(
 goto out;
 
 if ( (tss.trace & 1) && !exn_raised )
-hvm_inject_hw_exception(TRAP_debug, tss_sel & 0xfff8);
+hvm_inject_hw_exception(TRAP_debug, HVM_DELIVER_NO_ERROR_CODE);
 
 tr.attr.fields.type = 0xb; /* busy 32-bit tss */
 hvm_set_segment_register(v, x86_seg_tr, );
___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH 2/4] x86/HVM: unify and fix #UD intercept

2015-11-10 Thread Jan Beulich
The SVM and VMX versions really were identical, so instead of fixing
the same issue in two places, fold them at once. The issue fixed is the
missing seg:off -> linear translation of the current code address.

Signed-off-by: Jan Beulich 

--- a/xen/arch/x86/hvm/hvm.c
+++ b/xen/arch/x86/hvm/hvm.c
@@ -92,9 +92,12 @@ unsigned long __section(".bss.page_align
 static bool_t __initdata opt_hap_enabled = 1;
 boolean_param("hap", opt_hap_enabled);
 
-#ifndef opt_hvm_fep
-bool_t opt_hvm_fep;
+#ifndef NDEBUG
+/* Permit use of the Forced Emulation Prefix in HVM guests */
+static bool_t opt_hvm_fep;
 boolean_param("hvm_fep", opt_hvm_fep);
+#else
+#define opt_hvm_fep 0
 #endif
 
 /* Xen command-line option to enable altp2m */
@@ -4931,6 +4934,49 @@ gp_fault:
 return X86EMUL_EXCEPTION;
 }
 
+void hvm_ud_intercept(struct cpu_user_regs *regs)
+{
+struct hvm_emulate_ctxt ctxt;
+
+if ( opt_hvm_fep )
+{
+struct vcpu *cur = current;
+struct segment_register cs;
+unsigned long addr;
+char sig[5]; /* ud2; .ascii "xen" */
+
+hvm_get_segment_register(cur, x86_seg_cs, );
+if ( hvm_virtual_to_linear_addr(x86_seg_cs, , regs->eip,
+sizeof(sig), hvm_access_insn_fetch,
+(hvm_long_mode_enabled(cur) &&
+ cs.attr.fields.l) ? 64 :
+cs.attr.fields.db ? 32 : 16, ) &&
+ (hvm_fetch_from_guest_virt_nofault(sig, addr, sizeof(sig),
+0) == HVMCOPY_okay) &&
+ (memcmp(sig, "\xf\xbxen", sizeof(sig)) == 0) )
+{
+regs->eip += sizeof(sig);
+regs->eflags &= ~X86_EFLAGS_RF;
+}
+}
+
+hvm_emulate_prepare(, regs);
+
+switch ( hvm_emulate_one() )
+{
+case X86EMUL_UNHANDLEABLE:
+hvm_inject_hw_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE);
+break;
+case X86EMUL_EXCEPTION:
+if ( ctxt.exn_pending )
+hvm_inject_trap();
+/* fall through */
+default:
+hvm_emulate_writeback();
+break;
+}
+}
+
 enum hvm_intblk hvm_interrupt_blocked(struct vcpu *v, struct hvm_intack intack)
 {
 unsigned long intr_shadow;
--- a/xen/arch/x86/hvm/svm/svm.c
+++ b/xen/arch/x86/hvm/svm/svm.c
@@ -2123,43 +2123,6 @@ svm_vmexit_do_vmsave(struct vmcb_struct
 return;
 }
 
-static void svm_vmexit_ud_intercept(struct cpu_user_regs *regs)
-{
-struct hvm_emulate_ctxt ctxt;
-int rc;
-
-if ( opt_hvm_fep )
-{
-char sig[5]; /* ud2; .ascii "xen" */
-
-if ( (hvm_fetch_from_guest_virt_nofault(
-  sig, regs->eip, sizeof(sig), 0) == HVMCOPY_okay) &&
- (memcmp(sig, "\xf\xbxen", sizeof(sig)) == 0) )
-{
-regs->eip += sizeof(sig);
-regs->eflags &= ~X86_EFLAGS_RF;
-}
-}
-
-hvm_emulate_prepare(, regs);
-
-rc = hvm_emulate_one();
-
-switch ( rc )
-{
-case X86EMUL_UNHANDLEABLE:
-hvm_inject_hw_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE);
-break;
-case X86EMUL_EXCEPTION:
-if ( ctxt.exn_pending )
-hvm_inject_trap();
-/* fall through */
-default:
-hvm_emulate_writeback();
-break;
-}
-}
-
 static int svm_is_erratum_383(struct cpu_user_regs *regs)
 {
 uint64_t msr_content;
@@ -2491,7 +2454,7 @@ void svm_vmexit_handler(struct cpu_user_
 break;
 
 case VMEXIT_EXCEPTION_UD:
-svm_vmexit_ud_intercept(regs);
+hvm_ud_intercept(regs);
 break;
 
 /* Asynchronous event, handled when we STGI'd after the VMEXIT. */
--- a/xen/arch/x86/hvm/vmx/vmx.c
+++ b/xen/arch/x86/hvm/vmx/vmx.c
@@ -2747,43 +2747,6 @@ void vmx_enter_realmode(struct cpu_user_
 regs->eflags |= (X86_EFLAGS_VM | X86_EFLAGS_IOPL);
 }
 
-static void vmx_vmexit_ud_intercept(struct cpu_user_regs *regs)
-{
-struct hvm_emulate_ctxt ctxt;
-int rc;
-
-if ( opt_hvm_fep )
-{
-char sig[5]; /* ud2; .ascii "xen" */
-
-if ( (hvm_fetch_from_guest_virt_nofault(
-  sig, regs->eip, sizeof(sig), 0) == HVMCOPY_okay) &&
- (memcmp(sig, "\xf\xbxen", sizeof(sig)) == 0) )
-{
-regs->eip += sizeof(sig);
-regs->eflags &= ~X86_EFLAGS_RF;
-}
-}
-
-hvm_emulate_prepare(, regs);
-
-rc = hvm_emulate_one();
-
-switch ( rc )
-{
-case X86EMUL_UNHANDLEABLE:
-hvm_inject_hw_exception(TRAP_invalid_op, HVM_DELIVER_NO_ERROR_CODE);
-break;
-case X86EMUL_EXCEPTION:
-if ( ctxt.exn_pending )
-hvm_inject_trap();
-/* fall through */
-default:
-hvm_emulate_writeback();
-break;
-}
-}
-
 static int vmx_handle_eoi_write(void)
 {
 unsigned long exit_qualification;
@@ -3138,7 +3101,7 @@ void vmx_vmexit_handler(struct 

Re: [Xen-devel] [PATCH V8 3/7] libxl: add pvusb API

2015-11-10 Thread Ian Jackson
George Dunlap writes ("Re: [Xen-devel] [PATCH V8 3/7] libxl: add pvusb API"):
> On Tue, Nov 10, 2015 at 8:41 AM, Chun Yan Liu  wrote:
> > Which cast? Here, we want to get a uint_8 value, but buf is a string,
> > we need to do atoi.
> 
> atoi() isn't a cast, it's a function call.  The cast is the (char *) bit.
> 
> I think probably you could get away with declaring buf as (char *).
>  should be converted to void** automatically without any warnings,
> I think.

No, char** won't be automatically converted to void**.  But void* will
be automatically converted to char*.

(Will read the rest of this thread later, probably tomorrow.)

Ian.

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH 4/4] x86/traps: honor EXT bit in error codes

2015-11-10 Thread Andrew Cooper
On 10/11/15 17:40, Jan Beulich wrote:
> The specification does not explicitly limit the use of this bit to
> exceptions that can have selector style error codes, so to be on the
> safe side we should deal with it being set even on error codes formally
> documented to be always zero (if they're indeed always zero, the change
> is simply dead code in those cases).
>
> Introduce and use (where suitable) X86_XEC_* constants to make the code
> easier to read.
>
> To match the placement of the "hardware_trap" lable, the "hardware_gp"
> one gets moved slightly too.
>
> Signed-off-by: Jan Beulich 
>
> --- a/xen/arch/x86/cpu/mcheck/mce.c
> +++ b/xen/arch/x86/cpu/mcheck/mce.c
> @@ -431,16 +431,16 @@ static enum mce_result mce_action(const
>  
>  /*
>   * Return:
> - * -1: if system can't be recovered
> + * 1: if system can't be recovered
>   * 0: Continue to next step
>   */
> -static int mce_urgent_action(const struct cpu_user_regs *regs,
> -  mctelem_cookie_t mctc)
> +static bool_t mce_urgent_action(const struct cpu_user_regs *regs,
> +mctelem_cookie_t mctc)
>  {
>  uint64_t gstatus;
>  
> -if ( mctc == NULL)
> -return 0;
> +if ( regs->error_code & X86_XEC_EXT )
> +return 1;

#MC doesn't push an error code.  0 is pushed by the machine check handler.

>  
>  gstatus = mca_rdmsr(MSR_IA32_MCG_STATUS);
>  
> @@ -455,9 +455,9 @@ static int mce_urgent_action(const struc
>   */
>  if ( !(gstatus & MCG_STATUS_RIPV) &&
>   (!(gstatus & MCG_STATUS_EIPV) || !guest_mode(regs)) )
> -return -1;
> +return 1;
>  
> -return mce_action(regs, mctc) == MCER_RESET ? -1 : 0;
> +return mctc && mce_action(regs, mctc) == MCER_RESET;
>  }
>  
>  /* Shared #MC handler. */
> --- a/xen/arch/x86/traps.c
> +++ b/xen/arch/x86/traps.c
> @@ -618,6 +618,9 @@ static void do_trap(struct cpu_user_regs
>  unsigned int trapnr = regs->entry_vector;
>  unsigned long fixup;
>  
> +if ( use_error_code && (regs->error_code & X86_XEC_EXT) )

In the case that use_error_code is 0, regs->error_code will be filled
with 0.

Looking at the code, the parameter is redundant and could be derived
from regs->entry_vector alone.

> +goto hardware_trap;
> +
>  DEBUGGER_trap_entry(trapnr, regs);
>  
>  if ( guest_mode(regs) )
> @@ -644,6 +647,7 @@ static void do_trap(struct cpu_user_regs
>  return;
>  }
>  
> + hardware_trap:
>  DEBUGGER_trap_fatal(trapnr, regs);
>  
>  show_execution_state(regs);
> @@ -1265,13 +1269,14 @@ static int handle_gdt_ldt_mapping_fault(
>  tb = propagate_page_fault(curr->arch.pv_vcpu.ldt_base + offset,
>regs->error_code);
>  if ( tb )
> -tb->error_code = ((u16)offset & ~3) | 4;
> +tb->error_code = (offset & ~(X86_XEC_EXT | X86_XEC_IDT)) |
> + X86_XEC_TI;
>  }
>  }
>  else
>  {
>  /* GDT fault: handle the fault as #GP(selector). */
> -regs->error_code = (u16)offset & ~7;
> +regs->error_code = offset & ~(X86_XEC_EXT | X86_XEC_IDT | 
> X86_XEC_TI);
>  (void)do_general_protection(regs);
>  }
>  
> @@ -3231,7 +3236,7 @@ void do_general_protection(struct cpu_us
>  
>  DEBUGGER_trap_entry(TRAP_gp_fault, regs);
>  
> -if ( regs->error_code & 1 )
> +if ( regs->error_code & X86_XEC_EXT )
>  goto hardware_gp;
>  
>  if ( !guest_mode(regs) )
> @@ -3257,7 +3262,7 @@ void do_general_protection(struct cpu_us
>   * instruction. The DPL specified by the guest OS for these vectors is 
> NOT
>   * CHECKED!!
>   */
> -if ( (regs->error_code & 3) == 2 )
> +if ( regs->error_code & X86_XEC_IDT )

The code here has changed.  It is still technically correct because EXT
breaks earlier, but please do update the comment which currently talks
about the EXT check you have just removed.

~Andrew

>  {
>  /* This fault must be due to  instruction. */
>  const struct trap_info *ti;
> @@ -3299,9 +3304,9 @@ void do_general_protection(struct cpu_us
>  return;
>  }
>  
> + hardware_gp:
>  DEBUGGER_trap_fatal(TRAP_gp_fault, regs);
>  
> - hardware_gp:
>  show_execution_state(regs);
>  panic("GENERAL PROTECTION FAULT\n[error_code=%04x]", regs->error_code);
>  }
> --- a/xen/arch/x86/x86_64/entry.S
> +++ b/xen/arch/x86/x86_64/entry.S
> @@ -338,7 +338,7 @@ int80_slow_path:
>   * Setup entry vector and error code as if this was a GPF caused by 
> an
>   * IDT entry with DPL==0.
>   */
> -movl  $((0x80 << 3) | 0x2),UREGS_error_code(%rsp)
> +movl  $((0x80 << 3) | X86_XEC_IDT),UREGS_error_code(%rsp)
>  SAVE_PRESERVED
>  movl  $TRAP_gp_fault,UREGS_entry_vector(%rsp)
>  /* A GPF wouldn't have incremented the instruction pointer. */
> --- 

[Xen-devel] [PATCH v3 4/4] docs: Document xenstore paths for domain network address information

2015-11-10 Thread Paul Durrant
It is useful to be able to see the network addresses in use by a domain
for a particular vif in xenstore, for example so that ssh can be invoked
by a toolstack to log into the guest domain.

This patch documents paths to allow a domain to advertise MAC (unicast
and multicast) and IP (versions 4 and 6) address information.

Signed-off-by: Paul Durrant 
Cc: Ian Campbell 
Cc: Ian Jackson 
Cc: Jan Beulich 
Cc: Keir Fraser 
Cc: Tim Deegan 
---

v2:
 - Allow for compression of IPv6 addresses
---
 docs/misc/xenstore-paths.markdown | 30 ++
 1 file changed, 30 insertions(+)

diff --git a/docs/misc/xenstore-paths.markdown 
b/docs/misc/xenstore-paths.markdown
index 6fecdf3..cca29e6 100644
--- a/docs/misc/xenstore-paths.markdown
+++ b/docs/misc/xenstore-paths.markdown
@@ -39,6 +39,8 @@ before regexp expansion:
 * $UUID -- a UUID in the form ----
 * $NAME -- a string identifying an object within a domain. Typically
   comprising only alphanumeric characters.
+* $INDEX -- an integer used as part of a path when listing a set of
+values. Typically these integers are contiguous.
 
 VALUES are strings and can take the following forms:
 
@@ -58,6 +60,14 @@ VALUES are strings and can take the following forms:
  non-numeric character).
  The integers are a version number of the form MAJOR,
  MAJOR.MINOR or MAJOR.MINOR.MICRO respectively.
+* MAC_ADDRESS -- 6 integers, in hexadecimal form, separated by ':',
+ specifying an ethernet MAC address.
+* IPV4_ADDRESS -- 4 integers, in decimal form, separated by '.',
+  specifying an IP version 4 address.
+* IPV6_ADDRESS -- Up to 8 integers, in hexadecimal form, separated
+  by ':', specifying an IP version 6 address.
+ (Zero compression of addresses, using '::' notation,
+ is allowed but not required).
 
 Additional TAGS may follow as a comma separated set of the following
 tags enclosed in square brackets.
@@ -401,6 +411,26 @@ An HVM domain can indicate to a toolstack that it is 
capable
 of responding to instantiation of a new vbd by bringing online a
 new PV block device without the need for a reboot.
 
+ ~/attr/vif/$DEVID/name = STRING [w]
+
+A domain may write its internal 'friendly' name for a network device
+using this path.
+
+ ~/attr/vif/$DEVID/mac/$INDEX = MAC_ADDRESS [w]
+
+A domain may write the set of MAC addresses (unicast and multicast)
+in use by the network frontend using paths of this form.
+
+ ~/attr/vif/$DEVID/ipv4/$INDEX = IPV4_ADDRESS [w]
+
+A domain may write the set of IP version 4 addresses in use by the
+stack bound to the network frontend using paths of this form.
+
+ ~/attr/vif/$DEVID/ipv6/$INDEX = IPV6_ADDRESS [w]
+
+A domain may write the set of IP version 6 addresses in use by the
+stack bound to the network frontend using paths of this form.
+
 ### Paths private to the toolstack
 
  ~/device-model/$DOMID/state [w]
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v9 15/17] vmx: VT-d posted-interrupt core logic handling

2015-11-10 Thread Dario Faggioli
On Tue, 2015-11-03 at 16:43 +0800, Feng Wu wrote:
> This patch includes the following aspects:
> - Handling logic when vCPU is blocked:
> * Add a global vector to wake up the blocked vCPU
>   when an interrupt is being posted to it (This part
>   was sugguested by Yang Zhang ).
> * Define two per-cpu variables:
>   1. pi_blocked_vcpu:
> A list storing the vCPUs which were blocked
> on this pCPU.
> 
>   2. pi_blocked_vcpu_lock:
> The spinlock to protect pi_blocked_vcpu.
> 
> - Add the following hooks, this part was suggested
>   by George Dunlap  and
>   Dario Faggioli .
> * arch_vcpu_block()
>   Called alled before vcpu is blocking and update the PID
>   (posted-interrupt descriptor).
> 
> * vmx_pi_switch_from()
>   Called before context switch, we update the PID when the
>   vCPU is preempted or going to sleep.
> 
> * vmx_pi_switch_to()
>   Called after context switch, we update the PID when the vCPU
>   is going to run.
> 
> - Before VM-entry, check the state of PI descriptor, make sure the
> 'NV' field is set to '_intr_vector' when the guest is running
> in non-root mode. Suggested by Jan Beulich .
> 
So, TBH, I never felt in love with this changelog. I'm saying this now
because I'm starting to loose track of things, and the changelog is not
helpful as it could be, in explaining to me what this patch (and, in
this case, this particular version of the patch) does.

In fact, above, you're listing the functions and the data structure you
are adding, and some of the places from where they're called/used.
That, however, can all be figured out from the code.

I think this would want to become a bit more high level, and try to
describe the _reason_why_ the various bits and pieces have been put in
the shape they are. For instance, although you added a paragraph about
the VMENTRY check, it is not clear to me, by just reading this
description, that it is meant at avoiding having to add much more
hooks, as well as, as another example, what you put in the other email
about it needing to be called on ever VMENTRY (the "we can't use
vmx_do_resume() thing).

I'm not saying you should rewrite another design document in this
changelog, and I know it's hard to pick the best structure and content,
but, really, this isn't ideal.

Also, explicitly crediting people who suggested the various items is
not helpful too. In 5 years someone (either of us or new), won't care
much who actually came up with the idea of having hooks. What he'll
care, is for the changelog to provide guidance throughout what the code
does, and why it's been done that way. There is no trace of a similar
crediting scheme (which, in principle, it would apply to any, o at
least to major, comments you get at each review) in our history, and it
makes the changelog heavier to read, so I'd cut it all off.

> ---
> v9:
> - Remove arch_vcpu_block_cancel() and arch_vcpu_wake_prepare()
> - Add vmx_pi_state_change() and call it before VM Entry
> 
And this is why I said I'm losing track of what was your actual aim for
this round.

Since when the possibility of moving stuff to VMX helpers came out

Jan said, during v7 review (about the need to undo what
arch_vcpu_block() does in case local_evnts_need_delivery() is true):

1) "Couldn't this be taken care of by, if necessary, adjusting PI state
in vmx_do_resume()?"

And George said:

2) "we could just clear SN on every vmexit, and set SN and NDST on 
every vmentry, couldn't we?  Then we wouldn't need hooks on the 
context switch path at all (which are only there to catch running
-> runnable and runnable -> running) -- we could just have the 
block/unblock hooks (to change NV and add / remove things from the 
list)."

Then, during v8, review comments focused mostly on 1), because we felt
the need to try to get rid of the block-cancelling hook.

What you seem to have done in this patch, is something in the middle.
In fact, AFAIU:
 - the block-cancelling hook is no longer there,
 - the wakeup hooks are gone as well,
 - the context switch hooks are still there.

Now, I'm not saying that this is not satisfactory as a result, I'm
saying it's hard to keep track of what's going on and to figure out
what your aim was in this round (and hence check the aim against the
review comments, and the implementation against the aim).

If describing that does not fit in the changelog (e.g., because it
would be something about how the code is evolving, as it probably is),
then put it in the cover letter (this very patch is almost the only
thing being changed significantly in the series anyway), or in a few
paragraph, here, after the "---", above the v9 bulleted list of
changes.

> diff --git a/xen/arch/x86/hvm/vmx/vmx.c b/xen/arch/x86/hvm/vmx/vmx.c
> index e448b31..09c9c08 100644
> --- a/xen/arch/x86/hvm/vmx/vmx.c
> 

[Xen-devel] [PATCH v3 0/4] docs: Document xenstore paths

2015-11-10 Thread Paul Durrant
Patch #1 documents paths, some already in used by XenServer, which can be
used by guests to advertise contol capabilities.

Patch #2 documents paths which can be used to advertise PV driver versions.

Patch #3 documents paths which can be used by guests to advertise hotplug
capabilities.

Patch #4 documents paths which can be used by guests to advertise network
addresses.

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH v3 3/4] docs: Document xenstore paths for domain hotplug features

2015-11-10 Thread Paul Durrant
Without some indication from a domain it is not possible for a
toolstack to know whether instantiation of a new vbd or vif should
result in a new PV device of the appropriate type being instantiated
in a guest. (In other words whether PV drivers are present and
functioning).

This patch documents two paths which vif and vbd frontend drivers can
use to advertise their ability to respond to new vif or vbd
instantiations.

Signed-off-by: Paul Durrant 
Cc: Ian Campbell 
Cc: Ian Jackson 
Cc: Jan Beulich 
Cc: Keir Fraser 
Cc: Tim Deegan 
---

v2:
 - Drop HVM restriction
---
 docs/misc/xenstore-paths.markdown | 12 
 1 file changed, 12 insertions(+)

diff --git a/docs/misc/xenstore-paths.markdown 
b/docs/misc/xenstore-paths.markdown
index cae5115..6fecdf3 100644
--- a/docs/misc/xenstore-paths.markdown
+++ b/docs/misc/xenstore-paths.markdown
@@ -389,6 +389,18 @@ A domain writable path. Available for arbitrary domain use.
 A domain may write version information for PV driver $NAME using
 this path.
 
+ ~/feature/hotplug/vif = ("0"|"1") [w]
+
+An HVM domain can indicate to a toolstack that it is capable
+of responding to instantiation of a new vif by bringing online a
+new PV network device without the need for a reboot.
+
+ ~/feature/hotplug/vbd = ("0"|"1") [w]
+
+An HVM domain can indicate to a toolstack that it is capable
+of responding to instantiation of a new vbd by bringing online a
+new PV block device without the need for a reboot.
+
 ### Paths private to the toolstack
 
  ~/device-model/$DOMID/state [w]
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH v3 2/4] docs: Document a xenstore path for PV driver version information...

2015-11-10 Thread Paul Durrant
...to be advertised by a guest.

For domain management purposes it is convenient to be able to see
PV driver version information in xenstore. The XAPI toolstack in
XenServer has always created a ~/drivers path for this purpose.

This patch documents that path and also adds a specification of how
it should be used.

Signed-off-by: Paul Durrant 
Cc: Ian Campbell 
Cc: Ian Jackson 
Cc: Jan Beulich 
Cc: Keir Fraser 
Cc: Tim Deegan 
---

v2:
 - Modify version specifier to allow for single-part version numbers
   and also arbitrary string suffix (e.g. '-debug')
---
 docs/misc/xenstore-paths.markdown | 12 
 1 file changed, 12 insertions(+)

diff --git a/docs/misc/xenstore-paths.markdown 
b/docs/misc/xenstore-paths.markdown
index 71dfda2..cae5115 100644
--- a/docs/misc/xenstore-paths.markdown
+++ b/docs/misc/xenstore-paths.markdown
@@ -37,6 +37,8 @@ before regexp expansion:
   the "other" domain. i.e. ~ refers to the domain providing a service
   while $DOMID is the consumer of that service.
 * $UUID -- a UUID in the form ----
+* $NAME -- a string identifying an object within a domain. Typically
+  comprising only alphanumeric characters.
 
 VALUES are strings and can take the following forms:
 
@@ -51,6 +53,11 @@ VALUES are strings and can take the following forms:
 * (VALUE | VALUE | ... ) -- a set of alternatives. Alternatives are
   separated by a "|" and all the alternatives are enclosed in "(" and
   ")".
+* VERSION -- 1, 2 or 3 integers, in decimal form separated by "."
+ followed by a STRING suffix (starting with the first
+ non-numeric character).
+ The integers are a version number of the form MAJOR,
+ MAJOR.MINOR or MAJOR.MINOR.MICRO respectively.
 
 Additional TAGS may follow as a comma separated set of the following
 tags enclosed in square brackets.
@@ -377,6 +384,11 @@ protocol definition.
 
 A domain writable path. Available for arbitrary domain use.
 
+ ~/drivers/$NAME/version = VERSION [w]
+
+A domain may write version information for PV driver $NAME using
+this path.
+
 ### Paths private to the toolstack
 
  ~/device-model/$DOMID/state [w]
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH 1/4] x86/HVM: don't inject #DB with error code

2015-11-10 Thread Andrew Cooper
On 10/11/15 17:38, Jan Beulich wrote:
> Signed-off-by: Jan Beulich 

Reviewed-by: Andrew Cooper 

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH v3 1/4] docs: Document control features the can be advertised by guests...

2015-11-10 Thread Paul Durrant
...via xenstore.

XenServer already makes use of ~/control/feature-suspend being written
to advertise guest capability of responding to 'suspend' when written to
~/control/shutdown and, since they are derived from XenServer drivers,
the Xen Project Windows PV drivers attempt to write this value. The write
currently fails for libxl provisioned VMs because ~/control is read-only
to the guest (only ~/control/shutdown is writable, for ackowledgement
purposes).

This patch documents feature-suspend and also a set of similar control
feature flags, so that that they may be added to libxl provisioned
guests by subsequent patches:

feature-halt: PV drivers/agent can halt the guest
feature-reboot: PV drivers/agent can reboot the guest
feature-s3: PV drivers/agent can trigger guest sleep (HVM only)
feature-s4: PV drivers/agent can trigger guest hibernate (HVM only)

The patch (bacause it adds features relating to S3 and S4 power states)
also clarifies that the initial set of platform properties mentioned are
booleans, and updates the specifier accordingly.

Signed-off-by: Paul Durrant 
Cc: Ian Campbell 
Cc: Ian Jackson 
Cc: Jan Beulich 
Cc: Keir Fraser 
Cc: Tim Deegan 
---

v3:
 - Changed feature-halt to feature-poweroff since writing 'poweroff' to
   control/shutdown is the currently implemented method of PV domain
   shutdown
---
 docs/misc/xenstore-paths.markdown | 38 +++---
 1 file changed, 35 insertions(+), 3 deletions(-)

diff --git a/docs/misc/xenstore-paths.markdown 
b/docs/misc/xenstore-paths.markdown
index d94ea9d..71dfda2 100644
--- a/docs/misc/xenstore-paths.markdown
+++ b/docs/misc/xenstore-paths.markdown
@@ -178,9 +178,9 @@ will not relocate guest memory.
 
 The BIOS used by this domain.
 
- ~/platform/* [HVM,INTERNAL]
+ ~/platform/* = ("0"|"1") [HVM,INTERNAL]
 
-Various platform properties.
+Various boolean platform properties.
 
 * acpi -- is ACPI enabled for this domain
 * acpi_s3 -- is ACPI S3 support enabled for this domain
@@ -321,12 +321,44 @@ by udev ("0") or will be run by the toolstack directly 
("1").
  ~/control/shutdown = (""|COMMAND) [w]
 
 This is the PV shutdown control node. A toolstack can write various
-commands here to cause various guest shutdown, reboot or suspend
+commands here to cause various guest halt, reboot or suspend
 activities. The guest acknowledges a request by writing the empty
 string back to the command node.
 
 The precise protocol is not yet documented.
 
+ ~/control/feature-poweroff = (""|"0"|"1") [w]
+
+This is initialized to "" by the toolstack but may be set to 0 or 1 by
+a guest to indicate that it is capable or incapable, respectively, of
+shutting down if 'poweroff' is written to ~/control/shutdown.
+
+ ~/control/feature-reboot = (""|"0"|"1") [w]
+
+This is initialized to "" by the toolstack but may be set to 0 or 1 by
+a guest to indicate that it is capable or incapable, respectively, of
+rebooting if 'reboot' is written to ~/control/shutdown.
+
+ ~/control/feature-suspend = (""|"0"|"1") [w]
+
+This is initialized to "" by the toolstack but may be set to 0 or 1 by
+a guest to indicate that it is capable or incapable, respectively, of
+suspending if 'suspend' is written to ~/control/shutdown.
+
+ ~/control/feature-s3 = (""|"0"|"1") [w,HVM]
+
+This is initialized to "" by the toolstack but may be set to 0 or 1 by
+a guest to indicate that it is capable or incapable, respectively, of
+triggering a guest sleep if 's3' is written to ~/control/shutdown and
+~/platform/acpi_s3 is 1.
+
+ ~/control/feature-s4 = (""|"0"|"1") [w,HVM]
+
+This is initialized to "" by the toolstack but may be set to 0 or 1 by
+a guest to indicate that it is capable or incapable, respectively, of
+triggering a guest hibernate if 's4' is written to ~/control/shutdown
+and ~/platform/acpi_s4 is 1.
+
  ~/control/platform-feature-multiprocessor-suspend = (0|1) []
 
 Indicates to the guest that this platform supports the multiprocessor
-- 
2.1.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v2 2/2] arm: export platform_op XENPF_settime64

2015-11-10 Thread Daniel De Graaf

On 09/11/15 12:32, sstabell...@kernel.org wrote:

From: Stefano Stabellini 

Call update_domain_wallclock_time at domain initialization, specifically
in arch_set_info_guest for vcpu0, like we do on x86.
Set time_offset_seconds to the number of seconds between phisical boot
and domain initialization: it is going to be used to get/set the
wallclock time.
Add time_offset_seconds to system_time when before calling do_settime,
so that system_time actually accounts for all the time in nsec between
machine boot and when the wallclock was set.



Signed-off-by: Stefano Stabellini 


Acked-by: dgde...@tycho.nsa.gov

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [OSSTEST PATCH 17/22] ts-xen-install: networking: Rename `nodhcp' to `ensurebridge'

2015-11-10 Thread Ian Jackson
This function does not (now) always undo the DHCP configuration.
Sometimes it leaves it.  Its main function is to ensure that we have
a bridge for use by guests.

So rename the function.

Signed-off-by: Ian Jackson 
Tested-by: Robert Ho 
---
v14: This patch was previously 4/4 of a miniature series containing
  a different way of dealing with the Nested HVM L1 DHCP problem.
---
 ts-xen-install |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/ts-xen-install b/ts-xen-install
index d9aa694..3d0f394 100755
--- a/ts-xen-install
+++ b/ts-xen-install
@@ -247,7 +247,7 @@ sub hosts () {
 });
 }
 
-sub nodhcp () {
+sub ensurebridge () {
 target_editfile_root($ho, "/etc/network/interfaces",
  "etc-network-interfaces", sub {
 my $physif= get_host_property($ho,'interface force',undef);
@@ -370,6 +370,6 @@ if ($checkmode) {
 adjustconfig();
 setupboot();
 setupinitd();
-nodhcp();
+ensurebridge();
 hosts();
 }
-- 
1.7.10.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [OSSTEST PATCH 11/22] sg-run-job: Break out per-host-prep and per-host-finish

2015-11-10 Thread Ian Jackson
No functional change.

We now call the per-host-ts finish steps unconditionally, rather than
only if !$need_build_host, per-host-ts is (complicated) no-op if
$need_build_host, since in that case $need_xen_hosts is {}.

Signed-off-by: Ian Jackson 
Tested by: Robert Ho 
---
v14: Squash typo fix from Robert into this patch
---
 sg-run-job |   31 +++
 1 file changed, 19 insertions(+), 12 deletions(-)

diff --git a/sg-run-job b/sg-run-job
index 66145b8..884a21d 100755
--- a/sg-run-job
+++ b/sg-run-job
@@ -23,6 +23,20 @@ source ./tcl/osstestlib.tcl
 readconfig
 source-method JobDB
 
+proc per-host-prep {} {
+per-host-ts .   host-ping-check-native/@ ts-host-ping-check
+per-host-ts .   xen-install/@ ts-xen-install
+per-host-ts .   xen-boot/@ts-host-reboot
+
+per-host-ts .   host-ping-check-xen/@ ts-host-ping-check
+per-host-ts .   =(*) {ts-leak-check basis}
+}
+
+proc per-host-finish {} {
+per-host-ts .   ={ts-leak-check check}
+per-host-ts !broken capture-logs/@(*) ts-logs-capture
+}
+
 proc run-job {job} {
 global jobinfo builds flight ok need_xen_hosts anyfailed
 
@@ -51,22 +65,15 @@ proc run-job {job} {
 if {$ok} { setstatus running  }
 
 per-host-ts broken  host-install/@(*) ts-host-install-twice
-per-host-ts .   host-ping-check-native/@ ts-host-ping-check
-per-host-ts .   xen-install/@ ts-xen-install
-per-host-ts .   xen-boot/@ts-host-reboot
-per-host-ts .   host-ping-check-xen/@ ts-host-ping-check
 
-per-host-ts .   =(*) {ts-leak-check basis}
+per-host-prep
 
 if {$ok} { catching-otherwise fail  run-job/$jobinfo(recipe)  }
-per-host-ts .   ={ts-leak-check check}
 
-if {!$need_build_host} {
-per-host-ts !broken capture-logs/@(*) ts-logs-capture
-} else {
-if {$anyfailed} {
-run-ts  !broken capture-logs  ts-logs-capture + host
-}
+per-host-finish
+
+if {$need_build_host && $anyfailed} {
+   run-ts  !broken capture-logs  ts-logs-capture + host
 }
 
 if {$ok} { setstatus pass }
-- 
1.7.10.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [OSSTEST PATCH 05/22] Nested hosts: Provide PDU power method

2015-11-10 Thread Ian Jackson
From: Robert Ho 

This `guest' power method uses VM create/destroy.  It is automatically
used for nested hosts.  It would not make much sense to configure it
manually.

For nested host/guest, its power on/off method shall be
its host invoke $(toolstack)->create/destroy method.

Signed-off-by: Robert Ho 
Signed-off-by: Ian Jackson 
Tested-by: Robert Ho 
---
v14: Mostly rewritten by iwj
---
 Osstest/PDU/guest.pm   |   59 
 Osstest/TestSupport.pm |2 +-
 2 files changed, 60 insertions(+), 1 deletion(-)
 create mode 100755 Osstest/PDU/guest.pm

diff --git a/Osstest/PDU/guest.pm b/Osstest/PDU/guest.pm
new file mode 100755
index 000..b6bf9a1
--- /dev/null
+++ b/Osstest/PDU/guest.pm
@@ -0,0 +1,59 @@
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2015 Intel.
+# 
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+# 
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see .
+
+
+package Osstest::PDU::guest;
+
+use strict;
+use warnings;
+use Switch;
+
+use Osstest;
+use Osstest::TestSupport;
+use IO::File;
+
+BEGIN {
+use Exporter ();
+our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
+$VERSION = 1.00;
+@ISA = qw(Exporter);
+@EXPORT  = qw();
+%EXPORT_TAGS = ( );
+
+@EXPORT_OK   = qw();
+}
+
+sub new {
+my ($class, $ho) = @_;
+return bless { Target => $ho }, $class;
+}
+
+sub pdu_power_state {
+my ($mo, $on) = @_;
+
+my $child = $mo->{Target};
+my $parent = $child->{Host};
+die "$child->{Name} ?" unless $parent;
+
+logm("power $child->{Name} nested on $parent->{Name} ".($on+0));
+if ($on) {
+   toolstack($parent)->create($child);
+} else {
+   toolstack($parent)->destroy($child);
+}
+}
+
+1;
diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 3145040..9a256a9 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -861,7 +861,7 @@ sub selecthost ($) {
$child->{Info} = [ "in", $parent->{Name}, @{ $parent->{Info} } ];
$child->{NestingLevel} = $parent->{NestingLevel}+1;
 
-   # $child->{Power} = 'guest';   todo
+   $child->{Power} = 'guest';
power_cycle_host_setup($child);
 
$child->{Properties}{Serial} = 'noop'; # todo
-- 
1.7.10.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH] xen/gntdev: Grant maps should not be subject to NUMA balancing

2015-11-10 Thread Boris Ostrovsky

On 11/10/2015 02:36 PM, Konrad Rzeszutek Wilk wrote:

On Tue, Nov 10, 2015 at 02:22:44PM -0500, Boris Ostrovsky wrote:

Doing so will cause the grant to be unmapped and then, during
fault handling, the fault to be mistakenly treated as NUMA hint
fault.

In addition, even if we those maps could partcipate in NUMA
balancing it wouldn't provide any benefit since we wouldn't be
able to determine physical page's node (even if/when VNUMA is
implemented).

Marking grant maps' VMAs as VM_IO will exclude them from being
part of NUMA balancing.


Should this be 'cc:sta...@vger.kernel.org' ?


This bug becomes a real problem with 4.4, now that NUMA balancing is on 
by default.


But we should probably include it in stable too. I'll resubmit it then 
with CC tag.


-boris





Signed-off-by: Boris Ostrovsky 
---
  drivers/xen/gntdev.c |2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index 67b9163..bf312df 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -802,7 +802,7 @@ static int gntdev_mmap(struct file *flip, struct 
vm_area_struct *vma)
  
  	vma->vm_ops = _vmops;
  
-	vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;

+   vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP | VM_IO;
  
  	if (use_ptemod)

vma->vm_flags |= VM_DONTCOPY;
--
1.7.1




___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [OSSTEST PATCH 01/22] cs-adjust-flight: Add some missing doc comment info

2015-11-10 Thread Ian Jackson
Signed-off-by: Ian Jackson 
---
v14: New patch
---
 cs-adjust-flight |8 
 1 file changed, 8 insertions(+)

diff --git a/cs-adjust-flight b/cs-adjust-flight
index 4bfef48..d70abf7 100755
--- a/cs-adjust-flight
+++ b/cs-adjust-flight
@@ -24,6 +24,14 @@
 #   . means all jobs
 #   ^   means $foo =~ m/^/
 #   /   means $foo =~ m//
+#
+# :
+#   
+#   new:
+#
+# options:
+#   -v  verbose - list changes to stderr
+#   -D  debugging output to stderr
 
 # This is part of "osstest", an automated testing framework for Xen.
 # Copyright (C) 2009-2013 Citrix Inc.
-- 
1.7.10.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [OSSTEST PATCH 12/22] sg-run-job: Provide infrastructure for layers of nesting

2015-11-10 Thread Ian Jackson
Provides nested-layer-descend, which can be called in an individual
test job at the appropriate point (after the L1 has been set up).

The inner host is a guest of the outer host; powering it off means
destroying it.  Putting the poweroff at this point in the loop, rather
than in per-host-finish, avoids powering off physical servers.  The
use of `.'  rather than `!.' for iffail means we do not power off
after failures (as we might want to preserve the state for debugging
etc).

Signed-off-by: Ian Jackson 
Tested-by: Robert Ho 
Signed-off-by: Robert Ho 
Acked-by: Ian Jackson 
---
v14: Squash syntax fix from Robert Ho into this patch
v15: Remove spurious "=" from final-poweroff step invocation
---
 sg-run-job |   21 -
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/sg-run-job b/sg-run-job
index 884a21d..172c87e 100755
--- a/sg-run-job
+++ b/sg-run-job
@@ -39,6 +39,7 @@ proc per-host-finish {} {
 
 proc run-job {job} {
 global jobinfo builds flight ok need_xen_hosts anyfailed
+global nested_layers_hosts
 
 set ok 1
 set anyfailed 0
@@ -52,6 +53,7 @@ proc run-job {job} {
 set need_xen_hosts $nh
 set need_build_host 0
 }
+set nested_layers_hosts {}
 
 catching-otherwise blockedcheck-not-blocked
 if {!$ok} return
@@ -70,7 +72,15 @@ proc run-job {job} {
 
 if {$ok} { catching-otherwise fail  run-job/$jobinfo(recipe)  }
 
-per-host-finish
+while 1 {
+   per-host-finish
+   
+   if {![llength $nested_layers_hosts]} break
+
+   per-host-ts . final-poweroff {ts-host-powercycle --power=0}
+
+set need_xen_hosts [lunappend nested_layers_hosts]
+}
 
 if {$need_build_host && $anyfailed} {
run-ts  !broken capture-logs  ts-logs-capture + host
@@ -247,6 +257,15 @@ proc per-host-ts {iffail ident script args} {
 }
 }
 
+proc nested-layer-descend {nested_hosts} {
+# We save need_xen_hosts on a stack in nested_layers_hosts
+# It gets popped again during the cleanup part of run-job
+global nested_layers_hosts need_xen_hosts
+lappend nested_layers_hosts $need_xen_hosts
+set need_xen_hosts $nested_hosts
+per-host-prep
+}
+
 #-- test recipes --
 
 proc need-hosts/test-debian-nomigr {} { return host }
-- 
1.7.10.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [OSSTEST PATCH 07/22] target_check_ip: Rename and improve from guest_check_ip

2015-11-10 Thread Ian Jackson
Make this function suitable for running on targets with static IP
addresses.  (Ie, on physical hosts.)  Accordingly, rename it and
adjust all call sites.

Signed-off-by: Ian Jackson 
Tested-by: Robert Ho 
---
v14: New patch
---
 Osstest/TestSupport.pm |   11 ++-
 ts-guest-localmigrate  |2 +-
 ts-guest-migrate   |2 +-
 ts-guest-saverestore   |2 +-
 4 files changed, 9 insertions(+), 8 deletions(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 9a256a9..325e2e3 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -95,7 +95,7 @@ BEGIN {
   prepareguest_part_lvmdisk prepareguest_part_diskimg
   prepareguest_part_xencfg
   guest_umount_lv guest_await guest_await_dhcp_tcp
-  guest_checkrunning guest_check_ip guest_find_ether
+  guest_checkrunning target_check_ip guest_find_ether
   guest_find_domid guest_check_up guest_check_up_quick
   guest_get_state guest_await_reboot
   guest_await_shutdown guest_await_destroy guest_destroy
@@ -730,8 +730,9 @@ sub dhcp_watch_setup ($$) {
 $gho->{DhcpWatch} = get_host_method_object($ho, 'DhcpWatch', $meth);
 }
 
-sub guest_check_ip ($) {
-my ($gho) = @_;
+sub target_check_ip ($) {
+my ($gho) = @_; # returns error message or undef
+return undef if $gho->{IpStatic};
 guest_find_ether($gho);
 $gho->{DhcpWatch}->check_ip($gho);
 }
@@ -871,7 +872,7 @@ sub selecthost ($) {
$msg .= " guest $child->{Guest} (@{ $child->{Info} })";
$msg .= " $child->{Ether}";
 
-   my $err = guest_check_ip($child);
+   my $err = target_check_ip($child);
$msg .= " ".(defined $err ? " $err" : $child->{Ip});
 
logm($msg);
@@ -1956,7 +1957,7 @@ sub guest_await_dhcp_tcp ($$) {
  " $gho->{TcpCheckPort}".
   " link/ip/tcp",
   sub {
-my $err= guest_check_ip($gho);
+my $err= target_check_ip($gho);
 return $err if defined $err;
 
 return
diff --git a/ts-guest-localmigrate b/ts-guest-localmigrate
index 8fe986d..85a0887 100755
--- a/ts-guest-localmigrate
+++ b/ts-guest-localmigrate
@@ -40,7 +40,7 @@ sub migrate () {
 guest_await_dhcp_tcp($gho, 5);
 guest_check_up($gho);
 
-my $err= guest_check_ip($gho);  die "$err $gho->{Name}" if defined $err;
+my $err= target_check_ip($gho);  die "$err $gho->{Name}" if defined $err;
 
 for (my $rep=1; $rep<=$reps; $rep++) {
 logm("== rep $rep ==");
diff --git a/ts-guest-migrate b/ts-guest-migrate
index b77d0de..505fab2 100755
--- a/ts-guest-migrate
+++ b/ts-guest-migrate
@@ -30,7 +30,7 @@ our $gho = selectguest($ARGV[2],$sho);
 
 sub migrate () {
 guest_checkrunning($sho,$gho) or die $gho->{Name};
-my $err= guest_check_ip($gho);  die "$err $gho->{Name}" if defined $err;
+my $err= target_check_ip($gho);  die "$err $gho->{Name}" if defined $err;
 toolstack($sho)->migrate($gho, $dho, $timeout{Migrate});
 }
 
diff --git a/ts-guest-saverestore b/ts-guest-saverestore
index 7e13d90..73883ef 100755
--- a/ts-guest-saverestore
+++ b/ts-guest-saverestore
@@ -26,7 +26,7 @@ our ($ho,$gho) = ts_get_host_guest(@ARGV);
 
 sub save () {
 guest_checkrunning($ho,$gho) or die $gho->{Name};
-my $err= guest_check_ip($gho);  die "$err $gho->{Name}" if defined $err;
+my $err= target_check_ip($gho);  die "$err $gho->{Name}" if defined $err;
 toolstack($ho)->save($gho,"image",200);
 target_ping_check_down($gho);
 }
-- 
1.7.10.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [OSSTEST PATCH 15/22] Nested HVM: Add test job to appropriate flights

2015-11-10 Thread Ian Jackson
From: Robert Ho 

Signed-off-by: longtao.pang 
Signed-off-by: Robert Ho 
Signed-off-by: Ian Jackson 
Tested-by: Robert Ho 
---
v14: Use default gueststorage_size, rather than setting runvar.
 Dropped acked from Ian Campbell.
---
 make-flight |   28 
 1 file changed, 28 insertions(+)

diff --git a/make-flight b/make-flight
index 28820f5..3dfe5dc 100755
--- a/make-flight
+++ b/make-flight
@@ -249,6 +249,33 @@ do_hvm_win7_x64_tests () {
 all_hostflags=$most_hostflags,hvm
 }
 
+do_hvm_debian_nested_tests () {
+  bios=$1
+
+  if [ $xenarch != amd64 -o $dom0arch != amd64 \
+  -o "x$qemuu_suffix" != "x-qemuu" ]; then
+return
+  fi
+
+  case $xenbranch in
+xen-3.*-testing)  return;;
+xen-4.0-testing)  return;;
+xen-4.1-testing)  return;;
+xen-4.2-testing)  return;;
+xen-4.3-testing)  return;;
+  esac
+
+  job_create_test test-$xenarch$kern-$dom0arch$qemuu_suffix-nested \
+test-nested xl $xenarch $dom0arch $qemuu_runvar\
+l1_image=debian-7.2.0-amd64-CD-1.iso   \
+l1_vifmodel='e1000'\
+l1_memsize='3072'  \
+l1_enable_nestedhvm='true' \
+l2_image=debian-7.2.0-amd64-CD-1.iso   \
+bios=$bios \
+all_hostflags=$most_hostflags,hvm
+}
+
 branch_debianhvm_arch () {
   case $branch in
 xen-unstable-smoke) echo i386;;
@@ -592,6 +619,7 @@ test_matrix_do_one () {
 do_hvm_rhel6_tests
 
 do_hvm_debian_tests
+do_hvm_debian_nested_tests seabios
 
   done # qemuu_suffix
 
-- 
1.7.10.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [OSSTEST PATCH 08/22] await_tcp(): Run check_ip on each loop iteration

2015-11-10 Thread Ian Jackson
From: Robert Ho 

await_tcp is often invoked after a reboot.

In this situation the target's IP address may change.  If this happens
while await_tcp is running, we would continue to poll the old IP address.
Fix this by running target_check_ip on each iteration.

Signed-off-by: Robert Ho 
Signed-off-by: Ian Jackson 
Tested-by: Robert Ho 
---
v14: Dropped change to selecthost, which was in code which is no
  longer present in this version of the series.
 Rewritten to use target_check_ip.
 Dropped IMO-unnecessary comment.
---
 Osstest/TestSupport.pm |5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 325e2e3..b70f19f 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -2029,9 +2029,10 @@ sub await_tcp ($$$) {
 my ($maxwait,$interval,$ho) = @_;
 target_adjust_timeout($ho,\$maxwait);
 poll_loop($maxwait,$interval,
-  "await tcp $ho->{Name} $ho->{TcpCheckPort}",
+  "await tcp $ho->{Name} $ho->{Ip} $ho->{TcpCheckPort}",
   sub {
-return target_tcp_check($ho,$interval);
+   return target_check_ip($ho) //
+   target_tcp_check($ho,$interval);
 });
 }
 
-- 
1.7.10.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [OSSTEST PATCH 06/22] DhcpWatch::leases: Fix a reporting message

2015-11-10 Thread Ian Jackson
This talks about `guest_check_ip', but this code is now factored out
into a method.  Use the correct method name in reporting.

Signed-off-by: Ian Jackson 
Tested-by: Robert Ho 
---
v14: New patch
---
 Osstest/DhcpWatch/leases.pm |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Osstest/DhcpWatch/leases.pm b/Osstest/DhcpWatch/leases.pm
index 9a74c40..b74ebf0 100644
--- a/Osstest/DhcpWatch/leases.pm
+++ b/Osstest/DhcpWatch/leases.pm
@@ -171,7 +171,7 @@ sub check_ip ($$) {
 }
 $gho->{Ip}= $best->{' addr'};
 
-report_once($gho, 'guest_check_ip', 
+report_once($gho, 'leases::check_ip', 
"guest $gho->{Name}: $gho->{Ether} $gho->{Ip}");
 return undef;
 }
-- 
1.7.10.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [OSSTEST PATCH 03/22] selecthost: Minor cleanups

2015-11-10 Thread Ian Jackson
Document the syntax for $ident.

Log the ident as well as the selected hostname.

Signed-off-by: Ian Jackson 
Tested-by: Robert Ho 
---
v14: New patch
---
 Osstest/TestSupport.pm |   16 +++-
 1 file changed, 15 insertions(+), 1 deletion(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index aa41952..5e88add 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -810,6 +810,20 @@ sub power_state ($$) {
 sub selecthost ($) {
 my ($ident) = @_;
 # must be run outside transaction
+
+# $ident is 
+#
+#  can be , typically "host" or "xxx_host"
+# which means look up the runvar $r{$ident} which
+# contains 
+# OR
+#  can be =
+# which means ignore  except for logging purposes etc.
+# and use 
+#
+#  uis  which means use that host (and all
+# its flags and properties from the configuration and database)
+
 my $name;
 if ($ident =~ m/=/) {
 $ident= $`;
@@ -917,7 +931,7 @@ sub selecthost ($) {
 
 $mjobdb->host_check_allocated($ho);
 
-logm("host: selected $ho->{Name} ".
+logm("host $ho->{Ident}: selected $ho->{Name} ".
 (defined $ho->{Ether} ? $ho->{Ether} : '').
 " $ho->{Ip}".
  (!$ho->{Shared} ? '' :
-- 
1.7.10.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [OSSTEST PATCH 21/22] Serial: Factor out Osstest::Serial::keys_real

2015-11-10 Thread Ian Jackson
The sympathy and xenuse serial modules had too much in common.  Factor
out the common code, which is now responsible for
  - knowledge of the Xen console switch
  - splitting strings up into individual keys
  - timing decisions
  - error trapping and logging

This new class is an abstract base class for the concrete serial
method classes, and calls back to its derived class to prepare, send
each actual key, and shut down.

There is some functional change: notably, after failure to send the
first debug key, sending the remainder will not be attempted.

Signed-off-by: Ian Jackson 
---
 Osstest/Serial/keys_real.pm |   69 +++
 Osstest/Serial/sympathy.pm  |   55 +++---
 Osstest/Serial/xenuse.pm|   51 ++--
 3 files changed, 102 insertions(+), 73 deletions(-)
 create mode 100644 Osstest/Serial/keys_real.pm

diff --git a/Osstest/Serial/keys_real.pm b/Osstest/Serial/keys_real.pm
new file mode 100644
index 000..5c0cabf
--- /dev/null
+++ b/Osstest/Serial/keys_real.pm
@@ -0,0 +1,69 @@
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2015 Citrix Inc.
+# 
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+# 
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+# 
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see .
+
+
+package Osstest::Serial::keys_real;
+
+# Base class providing debug keys for real serial ports.
+# Derived class is expected to provide:
+#   $mo->keys_prepare();
+#   $mo->keys_prepare($what,$str,$pause);
+#   $mo->keys_shutdown();
+
+
+use strict;
+use warnings;
+
+use Osstest::TestSupport;
+
+sub request_debug {
+my ($mo,$conswitch,$xenkeys,$guestkeys) = @_;
+
+if (!eval {
+   local ($SIG{'PIPE'}) = 'IGNORE';
+
+   $mo->keys_prepare();
+
+   $mo->keys_write('force attach', "\x05cf", 1); # ^E c f == force attach
+
+   my $debugkeys= sub {
+   my ($what, $keys) = @_;
+   foreach my $k (split //, $keys) {
+   $mo->keys_write("$what debug info request, debug key $k",
+   $k, 2);
+   }
+   };
+
+   $mo->keys_write('request for input to Xen', $conswitch, 1);
+   $debugkeys->('Xen', $xenkeys);
+   sleep(10);
+   $debugkeys->('guest', $guestkeys);
+   sleep(10);
+   $mo->keys_write("RET to dom0","$conswitch\r", 5);
+
+   $mo->keys_write('dettach', "\x05c.", 1); # ^E c . == disconnect
+
+   $mo->keys_shutdown();
+
+   1;
+}) {
+   warn "failed to send debug key(s): $@\n";
+   return 0;
+}
+return 1;
+}
+
+1;
diff --git a/Osstest/Serial/sympathy.pm b/Osstest/Serial/sympathy.pm
index d6bf425..fa34143 100644
--- a/Osstest/Serial/sympathy.pm
+++ b/Osstest/Serial/sympathy.pm
@@ -22,12 +22,13 @@ use warnings;
 
 use Osstest;
 use Osstest::TestSupport;
+use Osstest::Serial::keys_real;
 
 BEGIN {
 use Exporter ();
 our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
 $VERSION = 1.00;
-@ISA = qw(Exporter);
+@ISA = qw(Exporter Osstest::Serial::keys_real);
 @EXPORT  = qw();
 %EXPORT_TAGS = ( );
 
@@ -57,48 +58,28 @@ sub new {
 return bless $mo, $class;
 }
 
-sub request_debug {
-my ($mo,$conswitch,$xenkeys,$guestkeys) = @_;
+sub keys_prepare {
+}
 
-my $targhost= $mo->{Server};
+sub keys_write {
+my ($mo, $what,$str,$pause) = @_;
 
+my $targhost= $mo->{Server};
 my ($sshopts) = sshopts();
-my $sympwrite= sub {
-my ($what,$str,$pause) = @_;
-logm("sympathy sending $what");
-if (!eval {
-local ($SIG{'PIPE'}) = 'IGNORE';
-my $sock= $mo->{Socket};
-my $rcmd= "sympathy -c -k $sock -N >/dev/null";
-$rcmd= "alarm 5 $rcmd";
-open SYMPWRITE, "|ssh @$sshopts root\@$targhost '$rcmd'" or die $!;
-autoflush SYMPWRITE 1;
-print SYMPWRITE $str or die $!;
-sleep($pause);
-close SYMPWRITE or die "$? $!";
-1;
-}) {
-warn "failed to send $what: $@\n";
-return 0;
-}
-return 1;
-};
 
-my $debugkeys= sub {
-   my ($what, $keys) = @_;
-   foreach my $k (split //, $keys) {
-   $sympwrite->("$what debug info request, debug key $k", $k, 2);
-   }
-};
+logm("sympathy sending $what");
 
-$sympwrite->('request for input to Xen', 

[Xen-devel] [OSSTEST PATCH 16/22] ts-xen-install: Properly handle hosts without a static IP address

2015-11-10 Thread Ian Jackson
From: Robert Ho 

Check IpStatic, and if it is not set, provide a dhcp stanza in
/etc/network/interfaces, rather than an `inet static' one.

This is necessary for L1 nested hosts, because they don't have a
static IP address.

In principle this makes matters more correct for physical hosts
without static IP addresses, but these are currently not supported
by selecthost().

Signed-off-by: Robert Ho 
Signed-off-by: Ian Jackson 
Tested-by: Robert Ho 
---
v14: Only use `inet dhcp' if !$ho->{IpStatic}.
---
 ts-xen-install |5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/ts-xen-install b/ts-xen-install
index b511e2b..d9aa694 100755
--- a/ts-xen-install
+++ b/ts-xen-install
@@ -320,11 +320,14 @@ END
 /auto $iface\n/x;
 if (m/^\s* iface \s+ (?: $physif | xenbr0 ) \s+ inet \s /x) {
 $suppress= 1;
-print EO <{IpStatic} ? <{Ip}
 netmask $netmask
 gateway $gateway
+END
+iface $iface inet dhcp
+END
 $bridgex
 END
 }
-- 
1.7.10.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [OSSTEST PATCH v16 00/22] Nested HVM

2015-11-10 Thread Ian Jackson
This series is also available at:
  git://xenbits.xen.org/people/iwj/osstest.git
  http://xenbits.xen.org/git-http/people/iwj/osstest.git
in wip.nested-hvm.v16..wip.nested-hvm.v16

The first three of these patches are IMO ready to go in whenever.

The rest of them are ready, but are part of the Nested HVM support and
should wait for the whole series, or they're just dead code in-tree.

There are only three patches with substantial changes not yet seen on
xen-devel:

 + 20/22 HVM guests: Use qemu "pipe:" for serial output
 + 21/22 Serial: Factor out Osstest::Serial::keys_real
 * 22/22 Serial: Add new serial method object for

The first two are entirely new cleanup patches.  I have (fairly
lightly) tested them (and if this series goes into pretest will take
responsibility for fixing them up).

The final patch - for nested HVM L1 debug keys - is completely
untested.  I'm expecting Robert to test it and report back.

Ian: I'm not sure whether or not you want to review these.  About half
of the patches are mine; the other half are Robert's but have been
reviewed by me.  All but the last three have been tested by Robert.

Thanks,
Ian.

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [OSSTEST PATCH 20/22] HVM guests: Use qemu "pipe:" for serial output logging

2015-11-10 Thread Ian Jackson
Modern qemu has the "pipe:/PATH" character driver.  This opens
/PATH.in for reading and /PATH.out for writing.  In my tests, I found
that:
  - contrary to the documentation, they do not need to be pipes
(at least, /PATH.out can be a file)
  - but they must both already exist
  - qemu will follow symlinks, so /PATH.out can be a symlink to
a file
  - if /PATH.in is a fifo, qemu will tolerate other processes opening
it for writing, and writing things, only occasionally.  (Probably,
qemu opens it O_RDWR; or perhaps it reopens it after EOF.)

Use this feature to achieve the following:
  - guest serial output ends up in /var/log/xen/osstest-serial-GUEST.log
(which is already captured by ts-logs-capture) rather than
interleaved with qemu's stderr output (in the libxl-created logfile)
  - guest serial input comes from a pipe in /root which we can open
and write to if we want to talk to the guest

We are mostly interested in the final bullet point, because that will
allow us to send debug keys to the emulated serial port of an L1
nested HVM guest.

Looking at the source code of qemu in 4.2 and 4.6 I think the above
approach will work with all relevant qemu-xen's.

If the device model version is qemu-xen-traditional, `pipe:' is not
supported.  If device_model_version is not set, we will be using
whatever the xen.git we used defaults to.  For Xen 4.1 and earlier
that is qemu-xen-traditional, and I'm slightly loathe to break osstest
for those earlier versions.  There doesn't seem to be anything else in
the runvars that would clue us in.  So be cautious and do not use the
new feature unless device_model_version is explicitly set.

The nested tests are all -qemuu so set device_model_version.

Signed-off-by: Ian Jackson 
---
v16: New patch
---
 Osstest/TestSupport.pm |   12 +++-
 1 file changed, 11 insertions(+), 1 deletion(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 32f2956..0a47b52 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -1884,8 +1884,18 @@ END
# fd pointing to mini-os's console. IOW any such path used
# here ends up in the host logs in /var/log/xen/qemu-dm-$guest.log
$cfg .= "serial='file:/var/log/dm-serial.log'\n";
-} else {
+} elsif (!(defined $devmodel) || $devmodel =~ /traditional/) {
$cfg .= "serial='file:/dev/stderr'\n";
+} else {
+   my $logpath = "/var/log/xen/osstest-serial-$gho->{Name}.log";
+   my $basepath = "/root/$flight.$job.$gho->{Name}.serial";
+   target_cmd_root($ho, <

[Xen-devel] [OSSTEST PATCH 10/22] Toolstack::xl: Provide block_attach method

2015-11-10 Thread Ian Jackson
It is possible that this may work some of the time with xm, so I have
taken no measures to prevent it running then.

Signed-off-by: Ian Jackson 
Signed-off-by: Robert Hu 
Tested-by: Robert Hu 

v14: New patch
v15: Fix missing $ho assignment in block-attach method
---
 Osstest/Toolstack/xl.pm |9 +
 1 file changed, 9 insertions(+)

diff --git a/Osstest/Toolstack/xl.pm b/Osstest/Toolstack/xl.pm
index 0f8abed..d956bcd 100644
--- a/Osstest/Toolstack/xl.pm
+++ b/Osstest/Toolstack/xl.pm
@@ -109,4 +109,13 @@ sub restore () {
." $f", $timeout);
 }
 
+sub block_attach () {
+my ($self,$gho,$xldiskspec) = @_;
+die "quotes in $xldiskspec ?" if $xldiskspec =~ m/'/;
+my $ho = $self->{Host};
+my $gn = $gho->{Name};
+my $cmd = $self->{_VerboseCommand}." block-attach $gn '$xldiskspec'";
+target_cmd_root($ho, $cmd, 100);
+}
+
 1;
-- 
1.7.10.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH] xen/gntdev: Grant maps should not be subject to NUMA balancing

2015-11-10 Thread Konrad Rzeszutek Wilk
On Tue, Nov 10, 2015 at 02:22:44PM -0500, Boris Ostrovsky wrote:
> Doing so will cause the grant to be unmapped and then, during
> fault handling, the fault to be mistakenly treated as NUMA hint
> fault.
> 
> In addition, even if we those maps could partcipate in NUMA
> balancing it wouldn't provide any benefit since we wouldn't be
> able to determine physical page's node (even if/when VNUMA is
> implemented).
> 
> Marking grant maps' VMAs as VM_IO will exclude them from being
> part of NUMA balancing.
> 

Should this be 'cc:sta...@vger.kernel.org' ?


> Signed-off-by: Boris Ostrovsky 
> ---
>  drivers/xen/gntdev.c |2 +-
>  1 files changed, 1 insertions(+), 1 deletions(-)
> 
> diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
> index 67b9163..bf312df 100644
> --- a/drivers/xen/gntdev.c
> +++ b/drivers/xen/gntdev.c
> @@ -802,7 +802,7 @@ static int gntdev_mmap(struct file *flip, struct 
> vm_area_struct *vma)
>  
>   vma->vm_ops = _vmops;
>  
> - vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
> + vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP | VM_IO;
>  
>   if (use_ptemod)
>   vma->vm_flags |= VM_DONTCOPY;
> -- 
> 1.7.1
> 

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [PATCH RESEND] xen/gntdev: Grant maps should not be subject to NUMA balancing

2015-11-10 Thread Boris Ostrovsky
Doing so will cause the grant to be unmapped and then, during
fault handling, the fault to be mistakenly treated as NUMA hint
fault.

In addition, even if those maps could partcipate in NUMA
balancing, it wouldn't provide any benefit since we are unable
to determine physical page's node (even if/when VNUMA is
implemented).

Marking grant maps' VMAs as VM_IO will exclude them from being
part of NUMA balancing.

Signed-off-by: Boris Ostrovsky 
Cc: sta...@vger.kernel.org
---

- Added sta...@vger.kernel.org

 drivers/xen/gntdev.c |2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/drivers/xen/gntdev.c b/drivers/xen/gntdev.c
index 67b9163..bf312df 100644
--- a/drivers/xen/gntdev.c
+++ b/drivers/xen/gntdev.c
@@ -802,7 +802,7 @@ static int gntdev_mmap(struct file *flip, struct 
vm_area_struct *vma)
 
vma->vm_ops = _vmops;
 
-   vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP;
+   vma->vm_flags |= VM_DONTEXPAND | VM_DONTDUMP | VM_IO;
 
if (use_ptemod)
vma->vm_flags |= VM_DONTCOPY;
-- 
1.7.1


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v2 1/3] xsm/xen_version: Add XSM for the xen_version hypercall.

2015-11-10 Thread Daniel De Graaf

On 06/11/15 14:36, Konrad Rzeszutek Wilk wrote:

All of XENVER_* have now an XSM check.

The subops for XENVER_[compile_info|changeset|commandline|
extraversion] are now priviliged operations. To not break
guests we still return an string - but it is just ''.

The rest: XENVER_[version|capabilities|
parameters|get_features|page_size|guest_handle] behave
as before - allowed by default for all guests.

This is with the XSM default policy and with the dummy ones.

Signed-off-by: Konrad Rzeszutek Wilk 


Comments below, inline.

[...]

diff --git a/tools/flask/policy/policy/modules/xen/xen.te 
b/tools/flask/policy/policy/modules/xen/xen.te
index d35ae22..1ca0e65 100644
--- a/tools/flask/policy/policy/modules/xen/xen.te
+++ b/tools/flask/policy/policy/modules/xen/xen.te
@@ -73,6 +73,12 @@ allow dom0_t xen_t:xen2 {
  pmu_ctrl
  get_symbol
  };
+
+# Allow dom0 to use XENVER_compile_info|changeset|commandline]extraversion
+allow dom0_t xen_t:xen2 {
+version_priv
+};
+
  allow dom0_t xen_t:mmu memorymap;

  # Allow dom0 to use these domctls on itself. For domctls acting on other


Minor tweak: if you don't want to add the new to the block a few lines above,
the one-line permission syntax without braces (as seen below) looks better.

[...]

  DO(xen_version)(int cmd, XEN_GUEST_HANDLE_PARAM(void) arg)
  {
+bool_t deny = !!xsm_version_op(XSM_HOOK, cmd);
+


Since this call produces denials in the default policy, it should be marked
as XSM_OTHER.


diff --git a/xen/xsm/flask/policy/access_vectors 
b/xen/xsm/flask/policy/access_vectors
index effb59f..273459f 100644
--- a/xen/xsm/flask/policy/access_vectors
+++ b/xen/xsm/flask/policy/access_vectors
@@ -93,6 +93,8 @@ class xen2
  pmu_ctrl
  # PMU use (domains, including unprivileged ones, will be using this operation)
  pmu_use
+# XENVER_[compile_info|changeset|commandline|extraversion] usage.
+   version_priv
  }

  # Classes domain and domain2 consist of operations that a domain performs on
@@ -242,6 +244,8 @@ class domain2
  mem_sharing
  # XEN_DOMCTL_psr_cat_op
  psr_cat_op
+# XENVER_[version|capabilities|parameters|get_features|page_size|guest_handle].
+version_use
  }

  # Similar to class domain, but primarily contains domctls related to HVM 
domains



I think that both version_priv and version_use belong in the same access
vector (xen2) rather than placing version_use in domain2.

--
Daniel De Graaf
National Security Agency

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [OSSTEST PATCH 14/22] Nested HVM: Provide test-nested recipe

2015-11-10 Thread Ian Jackson
From: Robert Ho 

Signed-off-by: Robert Ho 
Signed-off-by: Ian Jackson 
Tested-by: Robert Ho 
---
v14: ts-nested-setup command line syntax updated.
v15: (Robert Ho) remove the unnecessary l1 destroy; as it will
 implicitly powered off by framework as a nested host.
 This change hasn't been confirmed by Ian Jackson yet; I
 plan to separate it as fix patch but by mistake squashed
 it in. Ian Jackson may want to revert this if he dosn't
 agree.
---
 sg-run-job |9 +
 1 file changed, 9 insertions(+)

diff --git a/sg-run-job b/sg-run-job
index 172c87e..a2527ca 100755
--- a/sg-run-job
+++ b/sg-run-job
@@ -348,6 +348,15 @@ proc run-job/test-pair-oneway {} {
 run-ts . =  ts-guest-stop  dst_host  + debian
 }
 
+proc need-hosts/test-nested {} {return host}
+proc run-job/test-nested {} {
+run-ts . = ts-debian-hvm-install + host l1
+run-ts . = ts-nested-setup + --define l1=host:l1
+nested-layer-descend l1
+run-ts . = ts-debian-hvm-install l1 l2
+run-ts . = ts-guest-stop l1 l2
+}
+
 proc test-guest-migr {g} {
 set to_reap [spawn-ts . = ts-migrate-support-check + host $g 1]
 set can_migrate [reap-ts $to_reap]
-- 
1.7.10.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [OSSTEST PATCH 02/22] cs-adjust-flight: Allow adjusting "this" flight

2015-11-10 Thread Ian Jackson
This allows cs-adjust-flight to be run by hand to adjust runvars, in a
flight being used with hand-invocation of ./ts-* scripts.

Signed-off-by: Ian Jackson 
---
v14: New patch
---
 cs-adjust-flight |8 
 1 file changed, 8 insertions(+)

diff --git a/cs-adjust-flight b/cs-adjust-flight
index d70abf7..7c2c384 100755
--- a/cs-adjust-flight
+++ b/cs-adjust-flight
@@ -28,6 +28,7 @@
 # :
 #   
 #   new:
+#   running: uses OSSTEST_FLIGHT (may be `constructing' too)
 #
 # options:
 #   -v  verbose - list changes to stderr
@@ -395,6 +396,13 @@ sub main () {
 verbose_discard();
 changes();
 });
+} elsif ($dstflightspec =~ m/^running:$/) {
+$dstflight = $ENV{OSSTEST_FLIGHT} // die;
+db_retry($dstflight,[qw(constructing running)],
+ $dbh_tests, [qw(flights)], sub {
+verbose_discard();
+changes();
+});
 } elsif ($dstflightspec =~ m/^new:/) {
 my $intended = $'; #';
 db_retry($dbh_tests, [qw(flights)], sub {
-- 
1.7.10.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [OSSTEST PATCH 19/22] Osstest/Testsupport.pm: use get_target_property() for some host setup

2015-11-10 Thread Ian Jackson
From: Robert Ho 

For nested cases, nested host can inherit its host's property for
dhcp watch setup and ether_prefix property setup.

Signed-off-by: Robert Ho 
Tested-by: Robert Ho 
---
v15: New patch
---
 Osstest/TestSupport.pm |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index cb496d2..32f2956 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -735,7 +735,7 @@ sub lv_dev_mapper ($$) {
 sub dhcp_watch_setup ($$) {
 my ($ho,$gho) = @_;
 
-my $meth = get_host_property($ho,'dhcp-watch-method',undef);
+my $meth = get_target_property($ho,'dhcp-watch-method',undef);
 $gho->{DhcpWatch} = get_host_method_object($ho, 'DhcpWatch', $meth);
 }
 
@@ -1583,7 +1583,7 @@ sub target_choose_vg ($$) {
 
 sub ether_prefix($) {
 my ($ho) = @_;
-my $prefix = get_host_property($ho, 'gen-ether-prefix-base');
+my $prefix = get_target_property($ho, 'gen-ether-prefix-base');
 $prefix =~ m/^(\w+:\w+):(\w+):(\w+)$/ or die "$prefix ?";
 my $lhs = $1;
 my $pv = (hex($2)<<8) | (hex($3));
-- 
1.7.10.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [OSSTEST PATCH 18/22] Osstest/Testsupport.pm: change target's default kernkind to 'pvops'

2015-11-10 Thread Ian Jackson
This is safe only if no existing flights would be affected.  (That is,
the meaning of no existing sets of runvars would be changed.)

To check whether this would make any difference I did some database
searches.  Since any time target_kernkind_check is called it sets a
corresponding `console' runvar, I can search for `console' without a
corresponding `kernkind'.  I ran this query:

  select * from (select *, (select name from runvars r2 where
  r2.flight=r1.flight and r2.job=r1.job and r2.name=
  replace(r1.name,'console','kernkind')) kk from runvars r1 where
  r1.name like '%console') iq where kk is null order by flight desc;

and it found nothing since flight 7682.  So I think we can change the
default.

Signed-off-by:  Ian Jackson 
Signed-off-by:  Robert Ho 
Tested-by:  Robert Ho 
---
v15: New patch
---
 Osstest/TestSupport.pm |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index b507ada..cb496d2 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -2065,7 +2065,7 @@ sub target_var ($$) {
 sub target_kernkind_check ($) {
 my ($gho) = @_;
 my $pfx= target_var_prefix($gho);
-my $kernkind= $r{$pfx."kernkind"};
+my $kernkind= $r{$pfx."kernkind"} // 'pvops';
 my $isguest= exists $gho->{Guest};
 if ($kernkind eq 'pvops') {
 store_runvar($pfx."rootdev", 'xvda') if $isguest;
-- 
1.7.10.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [OSSTEST PATCH 13/22] Nested HVM: Provide ts-nested-setup to help make L1 usable as a host

2015-11-10 Thread Ian Jackson
From: Robert Ho 

* Provide the L1 with some storage for its own guests' disks
* Install some packages in the L1
* Optionally, set a runvar defining the L1 for the rest of the job

The recipe is going to run ts-xen-install etc.

Signed-off-by: longtao.pang 
Signed-off-by: Robert Ho 
Signed-off-by: Ian Jackson 
Tested-by: Robert Ho 
---
v14: Use target_check_ip (renamed, earlier, in a new patch)
 ts-nested-setup now has a default gueststorage_size of 20G
  and this is implicitly used by make-flight.
 Adjusted for new selecthost nested host syntax and correspondingly
  completely changed invocation syntax.
 Only optionally sets the runvar, if you pass --define.  (This
  will make it easier to play around with interactively.)
 Broken the pieces of work out into subroutines for clarity.
 Comment about guest storage slightly edited and rewrapped.
 Guest storage runvars and perl variable names etc. renamed to
  `gueststorage' rather than `guest_storage'.
 LVM and VG names and perl variable names changed to be clearer.
 Install `ed' too.
 Use lv_create and toolstack()->block_attach.
 Dropped ack from Ian Campbell.
---
 ts-nested-setup |   99 +++
 1 file changed, 99 insertions(+)
 create mode 100755 ts-nested-setup

diff --git a/ts-nested-setup b/ts-nested-setup
new file mode 100755
index 000..f7e0ebd
--- /dev/null
+++ b/ts-nested-setup
@@ -0,0 +1,99 @@
+#!/usr/bin/perl -w
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2015 Intel Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see .
+
+use strict qw(vars);
+use DBI;
+use Osstest;
+use Osstest::Debian;
+use Osstest::TestSupport;
+
+tsreadconfig();
+
+our $dodefine;
+if (@ARGV && $ARGV[0] eq '--define') { $dodefine=1; shift @ARGV; }
+
+our ($l1_identspec) = @ARGV;
+
+my $l1 = selecthost($l1_identspec);
+my $l0 = $l1->{Host};
+
+die unless $l0;
+
+our $def_gueststorage_size = 2; # Mby
+
+sub packages () {
+# Faster to install packages while L1 is still running PVHVM
+target_install_packages_norec($l1, qw(lvm2 rsync ed genisoimage));
+}
+
+sub guest_storage () {
+# We need to attach an extra disk to the L1 guest to be used as L2
+# guest storage:
+#
+# When running in a nested HVM environment the L1 domain is acting
+# as both a guest to L0 and a host to L2 guests and therefore
+# potentially sees connections to two independent xenstore
+# instances, one provided by the L0 host and one which is provided
+# by the L1 instance of xenstore.
+#
+# Unfortunately the kernel is not capable of dealing with this and
+# is only able to cope with a single xenstore connection. Since
+# the L1 toolstack and L2 guests absolutely require xenstore to
+# function we therefore cannot use the L0 xenstore and therefore
+# cannot use PV devices (xvdX etc) in the L1 guest and must use
+# emulated devices (sdX etc).
+#
+# However at the moment we have not yet rebooted L1 into Xen and
+# so it does have PV devices available and sdb actually appears as
+# xvdb.  We could disable the Xen platform device and use emulated
+# devices for the install phase too but that would be needlessly
+# slow.
+# 
+# Instead, to avoid needing to even mention the name of xvdb or
+# sdb, we create the vg in l0.  When the l1 reboots it will
+# automatically find the empty vg we have created for it, and
+# target_choose_vg on l1 (which is used by all the guest creation
+# ts-* scripts) will use it since it has plenty of space.
+
+my $size = guest_var($l1,'gueststorage_size',$def_gueststorage_size);
+die "gueststorage_size is undefined" unless $size;
+
+my $outer_vg = target_choose_vg($l0, $size);
+my $outer_lv = "$l1->{Ident}_gueststorage_outer_lv";
+my $inner_vg = "$l1->{Ident}_gueststorage_vg";
+
+target_cmd_root($l0, "vgremove -f $inner_vg ||:");
+my $outer_lvdev = lv_create($l0, $outer_vg, $outer_lv, $size);
+
+target_cmd_root($l0, <block_attach($l1, "$outer_lvdev,raw,sdb,rw");
+# 

[Xen-devel] [OSSTEST PATCH 09/22] LVM: Break out lv_create

2015-11-10 Thread Ian Jackson
We are going to want to reuse this.

Signed-off-by: Ian Jackson 
Signed-off-by: Robert Ho 
Tested-by: Robert Ho 
---
v14: New patch
v15: Change some trivial typo, so to resolve conflicts with
 production tree.
---
 Osstest/TestSupport.pm |   15 +++
 1 file changed, 11 insertions(+), 4 deletions(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index b70f19f..b507ada 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -63,7 +63,7 @@ BEGIN {
   target_install_packages target_install_packages_norec
   target_jobdir target_extract_jobdistpath_subdir
   target_extract_jobdistpath
-  lv_dev_mapper
+  lv_create lv_dev_mapper
 
   poll_loop tcpconnect await_tcp
   contents_make_cpio file_simple_write_contents
@@ -713,6 +713,15 @@ sub poll_loop ($$$&) {
 logm("$what: ok. (${waited}s)");
 }
 
+sub lv_create () {
+my ($ho, $vg, $lv, $mb) = @_;
+my $lvdev = "/dev/$vg/$lv";
+target_cmd_root($ho, "lvremove -f $lvdev ||:");
+target_cmd_root($ho, "lvcreate -L ${mb}M -n $lv $vg");
+target_cmd_root($ho, "dd if=/dev/zero of=$lvdev count=10");
+return $lvdev;
+}
+
 sub lv_dev_mapper ($$) {
 my ($vg,$lv) = @_;
 $vg =~ s/-/--/g;
@@ -1692,9 +1701,7 @@ sub prepareguest ($$) {
 
 sub prepareguest_part_lvmdisk ($$$) {
 my ($ho, $gho, $disk_mb) = @_;
-target_cmd_root($ho, "lvremove -f $gho->{Lvdev} ||:");
-target_cmd_root($ho, "lvcreate -L ${disk_mb}M -n $gho->{Lv} $gho->{Vg}");
-target_cmd_root($ho, "dd if=/dev/zero of=$gho->{Lvdev} count=10");
+lv_create($ho, $gho->{Vg}, $gho->{Lv}, $disk_mb);
 }
 
 sub make_vhd ($$$) {
-- 
1.7.10.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [OSSTEST PATCH 22/22] Serial: Add new serial method object for `guest' type

2015-11-10 Thread Ian Jackson
From: Robert Ho 

L1 guests' serial ports are owned by qemu in L0.  We can send them
debug keys by writing to the qemu pipe.

(xl debug-key looks like it would be useful but it actually sends
debug keys to the hypervisor of the host it is running on.  We want to
send the debug keys to the hypervisor and kernel from the outside.)

Log fetching is not needed because from the POV of the L0 the L1 is a
guest, so the L0's log capture will already fetch the L1's serial
console output.

XXX THIS PATCH IS TOTALLY UNTESTED

Signed-off-by: Robert Ho 
Signed-off-by: Ian Jackson 

---
v16: Mostly rewritten: now uses new keys_real base class, and
 uses the qemu pipe rather than xl debug-keys.
v15: New patch.
---
 Osstest/Serial/guest.pm |   93 +++
 Osstest/TestSupport.pm  |2 +-
 2 files changed, 94 insertions(+), 1 deletion(-)
 create mode 100644 Osstest/Serial/guest.pm

diff --git a/Osstest/Serial/guest.pm b/Osstest/Serial/guest.pm
new file mode 100644
index 000..e2902ee
--- /dev/null
+++ b/Osstest/Serial/guest.pm
@@ -0,0 +1,93 @@
+# This is part of "osstest", an automated testing framework for Xen.
+# Copyright (C) 2015 Intel Inc.
+# Copyright (C) 2015 Citrix Inc.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with this program.  If not, see .
+
+# Send debug keys to nested host (L1).
+
+package Osstest::Serial::guest;
+
+use strict;
+use warnings;
+
+use Osstest;
+use Osstest::TestSupport;
+use Osstest::Serial::keys_real;
+
+BEGIN {
+use Exporter ();
+our ($VERSION, @ISA, @EXPORT, @EXPORT_OK, %EXPORT_TAGS);
+$VERSION = 1.00;
+@ISA = qw(Exporter Osstest::Serial::keys_real);
+@EXPORT  = qw();
+%EXPORT_TAGS = ( );
+
+@EXPORT_OK   = qw();
+}
+
+sub new {
+my ($class, $l1ho, $methname, @args) = @_;
+my $mo = { Target => $l1ho, Parent => $l1ho->{Host} };
+
+logm("serial method $methname $mo->{Target}{Name}: @args");
+return bless $mo, $class;
+}
+
+sub keys_prepare {
+my ($mo) = @_;
+
+my $gho = $mo->{Target};
+my $pho = $mo->{Parent};
+my $puho = sshuho('root',$pho);
+
+my $fifo = "/root/$flight.$job.$gho->{Name}.serial.in";
+
+# NB this by-hand construction and execution of an
+# ssh command line bypasses the usual timeout arrangements.
+my ($sshopts) = sshopts();
+
+# timeouts: open will carry on regardless even if the command hangs
+open SERIALWRITE, "|ssh @$sshopts $puho cat >$fifo" or die $!;
+autoflush SERIALWRITE 1;
+}
+
+sub keys_write {
+my ($mo, $what,$str,$pause) = @_;
+logm("xenuse sending $what");
+
+# timeouts: we are going to write much less than any plausible
+# PIPE_MAX so there is no risk that we will block on write
+print SERIALWRITE $str or die $!;
+sleep($pause);
+}
+
+sub keys_shutdown {
+my ($mo) = @_;
+
+# timeouts: close waits for the child to exit, so set an alarm
+alarm(15);
+$!=0; $?=0; close SERIALWRITE or die "$? $!";
+alarm(0);
+}
+
+sub fetch_logs {
+my ($mo);
+
+logm("$mo->{Target}{Name} (nested host) serial console logs".
+" will be found in guest logs from $mo->{Parent}{Name} (parent)");
+return;
+}
+
+1;
diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 0a47b52..bfc5652 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -874,7 +874,7 @@ sub selecthost ($) {
$child->{Power} = 'guest';
power_cycle_host_setup($child);
 
-   $child->{Properties}{Serial} = 'noop'; # todo
+   $child->{Properties}{Serial} = 'guest';
serial_host_setup($child);
 
my $msg = "L$child->{NestingLevel} host $child->{Ident}:";
-- 
1.7.10.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [OSSTEST PATCH 04/22] selecthost: Support nested hosts (guests which are also hosts)

2015-11-10 Thread Ian Jackson
We introduce a new syntax: instead of a hostname (which might appear
in a command line argument to a ts-* script and hence be passed to
selecthost, or which might be in a runvar), we now support
:.

Such `hosts' (let us refer to such a thing as an L1, although in
principle further nesting may be possible) are expected to be
dynamically created.  So they do not have flags and properties in the
configuration (or in an Executive instance's database).

The IP address is determined dynamically from the leases file.  If the
L1 is not running, then no IP address may be found.  This is not an
error.  Users of this facility will need to make sure that ts-*
scripts which are unaware of the L1's special status are only invoked
when it is known that the L1 is up and has obtained its IP address.

`Power cycling' the L1 will be done by VM control operations in the
L0; this will come in a subsequent patch.

`Serial access' to the L1 guest will likewise need to be done via the
console arrangements in L0.

Signed-off-by: Ian Jackson 
Tested-by: Robert Ho 
---
v14: New patch
---
 Osstest/TestSupport.pm |   37 -
 1 file changed, 36 insertions(+), 1 deletion(-)

diff --git a/Osstest/TestSupport.pm b/Osstest/TestSupport.pm
index 5e88add..3145040 100644
--- a/Osstest/TestSupport.pm
+++ b/Osstest/TestSupport.pm
@@ -807,6 +807,7 @@ sub power_state ($$) {
 
 #-- host selection and properties --
 
+sub selecthost ($);
 sub selecthost ($) {
 my ($ident) = @_;
 # must be run outside transaction
@@ -821,8 +822,12 @@ sub selecthost ($) {
 # which means ignore  except for logging purposes etc.
 # and use 
 #
-#  uis  which means use that host (and all
+#  can be  which means use that host (and all
 # its flags and properties from the configuration and database)
+# OR
+#  can be : meaning use the
+# Xen domain name  on the host specified by
+# , which is an  as above.
 
 my $name;
 if ($ident =~ m/=/) {
@@ -838,6 +843,7 @@ sub selecthost ($) {
 Ident => $ident,
 Name => $name,
 TcpCheckPort => 22,
+NestingLevel => 0,
 Info => [],
 };
 if (defined $job) {
@@ -845,6 +851,35 @@ sub selecthost ($) {
  $c{DebianSuite});
 }
 
+#- handle hosts which are themselves guests (nested) -
+
+if ($name =~ s/^(.*)://) {
+   my $parentname = $1;
+   my $parent = selecthost($parentname);
+   my $child = selectguest($name,$parent);
+   $child->{Ident} = $ho->{Ident};
+   $child->{Info} = [ "in", $parent->{Name}, @{ $parent->{Info} } ];
+   $child->{NestingLevel} = $parent->{NestingLevel}+1;
+
+   # $child->{Power} = 'guest';   todo
+   power_cycle_host_setup($child);
+
+   $child->{Properties}{Serial} = 'noop'; # todo
+   serial_host_setup($child);
+
+   my $msg = "L$child->{NestingLevel} host $child->{Ident}:";
+   $msg .= " guest $child->{Guest} (@{ $child->{Info} })";
+   $msg .= " $child->{Ether}";
+
+   my $err = guest_check_ip($child);
+   $msg .= " ".(defined $err ? " $err" : $child->{Ip});
+
+   logm($msg);
+
+   # all the rest of selecthost is wrong for this case
+   return $child;
+}
+
 #- calculation of the host's properties -
 
 $ho->{Properties} = { };
-- 
1.7.10.4


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] Osstest nested patch v15 (was RE: [OSSTEST PATCH v14 PART 2 10-26/26] Nested HVM testing)

2015-11-10 Thread Ian Jackson
Hu, Robert writes ("Osstest nested patch v15 (was RE: [OSSTEST PATCH v14 PART 2 
10-26/26] Nested HVM testing)"):
> I here hand over to you the v15 patch bundle as attached. Hope it can pass 
> your pretest soon.

Thanks.  (CCing the list.)

All of your fixes were good.  Thank you.  I have incorporated them.

> * The last patch of 'guest' Serial method, was made by myself, you
> may want to rewrite it or modify it. I don't have the
> confidence. But it doesn't blocks others, with or without it, the
> patch set can work fine.

I rewrote this.  I found I wanted to do some refactoring first to make
this easier.

I am going to send out a v16 of the whole series in just a moment.

Can you please test this final patch in your environment ?  Send me
fixes in whatever form you like.

I think we do need this debug keys feature to work before we push this
to osstest pretest, because otherwise we risk having un-debuggable
blocking failures in our CI.

Regards,
Ian.

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [qemu-mainline test] 63957: regressions - FAIL

2015-11-10 Thread osstest service owner
flight 63957 qemu-mainline real [real]
http://logs.test-lab.xenproject.org/osstest/logs/63957/

Regressions :-(

Tests which did not succeed and are blocking,
including tests which could not be run:
 test-armhf-armhf-xl-credit2   7 host-ping-check-xen   fail REGR. vs. 63705

Regressions which are regarded as allowable (not blocking):
 test-armhf-armhf-xl-rtds 11 guest-start  fail   like 63705

Tests which did not succeed, but are not blocking:
 test-amd64-amd64-xl-pvh-amd  11 guest-start  fail   never pass
 test-amd64-amd64-xl-pvh-intel 11 guest-start  fail  never pass
 test-armhf-armhf-libvirt-qcow2  9 debian-di-installfail never pass
 test-armhf-armhf-libvirt 14 guest-saverestorefail   never pass
 test-armhf-armhf-libvirt 12 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt-xsm 12 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt-xsm 14 guest-saverestorefail   never pass
 test-armhf-armhf-xl-xsm  13 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-xsm  12 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt 12 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt  12 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt-xsm 12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-arndale  12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-arndale  13 saverestore-support-checkfail   never pass
 test-amd64-amd64-xl-qemuu-win7-amd64 17 guest-stop fail never pass
 test-amd64-amd64-libvirt-vhd  9 debian-di-installfail   never pass
 test-amd64-i386-xl-qemuu-win7-amd64 17 guest-stop  fail never pass
 test-armhf-armhf-xl-vhd   9 debian-di-installfail   never pass
 test-amd64-i386-libvirt-xsm  12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  13 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl  12 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm 10 migrate-support-check 
fail never pass
 test-armhf-armhf-xl-multivcpu 13 saverestore-support-checkfail  never pass
 test-armhf-armhf-xl-multivcpu 12 migrate-support-checkfail  never pass
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm 10 migrate-support-check 
fail never pass
 test-armhf-armhf-xl-cubietruck 12 migrate-support-checkfail never pass
 test-armhf-armhf-xl-cubietruck 13 saverestore-support-checkfail never pass
 test-armhf-armhf-libvirt-raw  9 debian-di-installfail   never pass

version targeted for testing:
 qemuub3a9e57d92dff7dd5822f322e4eb49af9e1b70b8
baseline version:
 qemuu496c1b19facc7b850fa0c09899fcc07a0702fbfd

Last test of basis63705  2015-11-05 20:52:41 Z4 days
Failing since 63741  2015-11-07 01:13:47 Z3 days3 attempts
Testing same since63957  2015-11-09 12:09:07 Z1 days1 attempts


People who touched revisions under test:
  Cao jin 
  Daniel P. Berrange 
  Ed Maste 
  Eduardo Habkost 
  Eric Blake 
  Gonglei 
  John Snow 
  Julio Guerra 
  Kevin Wolf 
  Marc-André Lureau 
  Mark Cave-Ayland 
  Markus Armbruster 
  Michael Tokarev 
  Paolo Bonzini 
  Pavel Dovgalyuk 
  Peter Crosthwaite 
  Peter Crosthwaite 
  Peter Maydell 
  Roger Pau Monné 
  Stefan Hajnoczi 
  Stefano Stabellini 
  Thomas Huth 
  Xiao Guangrong 

jobs:
 build-amd64-xsm  pass
 build-armhf-xsm  pass
 build-i386-xsm   pass
 build-amd64  pass
 build-armhf  pass
 build-i386   pass
 build-amd64-libvirt  pass
 build-armhf-libvirt  pass
 build-i386-libvirt   pass
 build-amd64-pvopspass
 build-armhf-pvopspass
 build-i386-pvops pass
 

Re: [Xen-devel] [PATCH v2 2/8] xen: arm: fix typo in the description of struct pending_irq->desc

2015-11-10 Thread Julien Grall

Hi Ian,

On 10/11/2015 16:21, Ian Campbell wrote:

s/it/if/ makes more sense.

Signed-off-by: Ian Campbell 


Reviewed-by: Julien Grall 

Regards,


---
  xen/include/asm-arm/vgic.h | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/xen/include/asm-arm/vgic.h b/xen/include/asm-arm/vgic.h
index cb51a9e..7d580cc 100644
--- a/xen/include/asm-arm/vgic.h
+++ b/xen/include/asm-arm/vgic.h
@@ -66,7 +66,7 @@ struct pending_irq
  #define GIC_IRQ_GUEST_ENABLED  3
  #define GIC_IRQ_GUEST_MIGRATING   4
  unsigned long status;
-struct irq_desc *desc; /* only set it the irq corresponds to a physical 
irq */
+struct irq_desc *desc; /* only set if the irq corresponds to a physical 
irq */
  unsigned int irq;
  #define GIC_INVALID_LR ~(uint8_t)0
  uint8_t lr;



--
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v2 1/8] xen: arm: fix indendation of struct vtimer

2015-11-10 Thread Julien Grall

Hi Ian,

On 10/11/2015 16:21, Ian Campbell wrote:

Signed-off-by: Ian Campbell 


Reviewed-by: Julien Grall 

Regards,


---
  xen/include/asm-arm/domain.h | 10 +-
  1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/xen/include/asm-arm/domain.h b/xen/include/asm-arm/domain.h
index e7e40da..c56f06e 100644
--- a/xen/include/asm-arm/domain.h
+++ b/xen/include/asm-arm/domain.h
@@ -35,11 +35,11 @@ extern int dom0_11_mapping;
  #define is_domain_direct_mapped(d) ((d) == hardware_domain && dom0_11_mapping)

  struct vtimer {
-struct vcpu *v;
-int irq;
-struct timer timer;
-uint32_t ctl;
-uint64_t cval;
+struct vcpu *v;
+int irq;
+struct timer timer;
+uint32_t ctl;
+uint64_t cval;
  };

  struct arch_domain



--
Julien Grall

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


[Xen-devel] [linux-4.1 test] 63996: tolerable FAIL - PUSHED

2015-11-10 Thread osstest service owner
flight 63996 linux-4.1 real [real]
http://logs.test-lab.xenproject.org/osstest/logs/63996/

Failures :-/ but no regressions.

Regressions which are regarded as allowable (not blocking):
 test-amd64-amd64-rumpuserxen-amd64 15 
rumpuserxen-demo-xenstorels/xenstorels.repeat fail REGR. vs. 63341
 test-amd64-amd64-xl-qemut-win7-amd64 17 guest-stop fail like 63341
 test-amd64-amd64-xl-qemuu-win7-amd64 17 guest-stop fail like 63341

Tests which did not succeed, but are not blocking:
 test-amd64-amd64-xl-pvh-amd  11 guest-start  fail   never pass
 test-armhf-armhf-xl-vhd   9 debian-di-installfail   never pass
 test-armhf-armhf-libvirt-qcow2  9 debian-di-installfail never pass
 test-amd64-amd64-xl-pvh-intel 14 guest-saverestorefail  never pass
 test-armhf-armhf-libvirt 14 guest-saverestorefail   never pass
 test-armhf-armhf-libvirt 12 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt-xsm 12 migrate-support-checkfail   never pass
 test-armhf-armhf-libvirt-xsm 14 guest-saverestorefail   never pass
 test-armhf-armhf-libvirt-raw  9 debian-di-installfail   never pass
 test-amd64-i386-libvirt  12 migrate-support-checkfail   never pass
 test-amd64-amd64-libvirt-xsm 12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-arndale  12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-arndale  13 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl  12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl  13 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-rtds 13 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-rtds 12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-rtds 16 guest-start/debian.repeatfail   never pass
 test-amd64-amd64-libvirt 12 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt-xsm  12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-cubietruck 12 migrate-support-checkfail never pass
 test-armhf-armhf-xl-cubietruck 13 saverestore-support-checkfail never pass
 test-amd64-amd64-libvirt-qemuu-debianhvm-amd64-xsm 10 migrate-support-check 
fail never pass
 test-amd64-amd64-libvirt-vhd 11 migrate-support-checkfail   never pass
 test-amd64-i386-libvirt-qemuu-debianhvm-amd64-xsm 10 migrate-support-check 
fail never pass
 test-amd64-i386-xl-qemuu-win7-amd64 17 guest-stop  fail never pass
 test-amd64-i386-xl-qemut-win7-amd64 17 guest-stop  fail never pass
 test-armhf-armhf-xl-multivcpu 13 saverestore-support-checkfail  never pass
 test-armhf-armhf-xl-multivcpu 12 migrate-support-checkfail  never pass
 test-armhf-armhf-xl-xsm  13 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-xsm  12 migrate-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  13 saverestore-support-checkfail   never pass
 test-armhf-armhf-xl-credit2  12 migrate-support-checkfail   never pass

version targeted for testing:
 linux1f2ce4a2e7aea3a2123b17aff62a80553df31e21
baseline version:
 linux10f9e3bce7f3ab7ab4d09a9b78c7208c9a1455f7

Last test of basis63341  2015-10-28 05:31:51 Z   13 days
Testing same since63996  2015-11-09 23:07:34 Z0 days1 attempts


People who touched revisions under test:
  Adam J. Richter 
  Adam Richter 
  Akinobu Mita 
  Alex Deucher 
  Alexandre Belloni 
  Alim Akhtar 
  Andrei Otcheretianski 
  Andrew Morton 
  Andy Shevchenko 
  Antoine Tenart 
  Antti Palosaari 
  Ard Biesheuvel 
  Arik Nemtsov 
  Arik Nemtsov 
  Aristeu Rozanski 
  Arnd Bergmann 
  Avraham Stern 
  Ben Skeggs 
  Bjorn Helgaas 
  Bjørn Mork 
  Borislav Petkov 
  Brian Austin 
  Catalin Marinas 
  Cathy Avery 
  Charles Keepax 
  Chris Mason 
  Chris Wilson 
  Christian Engelmayer 
  Christian Zander 
  Christoffer Dall 
  Dan Carpenter 
  Daniel Vetter 
  Daniel Vetter 
  Dave Airlie 

Re: [Xen-devel] [PATCH V8 3/7] libxl: add pvusb API

2015-11-10 Thread Chun Yan Liu


>>> On 11/10/2015 at 02:11 AM, in message
<22080.57829.461049.37...@mariner.uk.xensource.com>, Ian Jackson
 wrote: 
> Chunyan Liu writes ("[PATCH V8 3/7] libxl: add pvusb API"): 
> > Add pvusb APIs, including: 
> >  - attach/detach (create/destroy) virtual usb controller. 
> >  - attach/detach usb device 
> >  - list usb controller and usb devices 
> >  - some other helper functions 
>  
> Thanks for this. 
>  
>  
> I have reviewed it in detail (not just the ao handling aspects) and 
> (I'm afraid) produced a large number of comments, relating to style, 
> error handling, etc., as well as ao handling. 
>  
> Please let me know if anything I've said is unclear.  I've been rather 
> brief in my comments, rather than writing a paragraph for each one. 
> Thanks. 
>  
>  
> > diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c 
> > index dacfaae..a050e8b 100644 
> > --- a/tools/libxl/libxl.c 
> > +++ b/tools/libxl/libxl.c 
> > @@ -4218,11 +4218,54 @@ DEFINE_DEVICE_REMOVE(vtpm, destroy, 1) 
> ... 
> > +/* Macro for defining device remove/destroy functions for usbctrl */ 
> > +/* Following functions are defined: 
> > + * libxl_device_usbctrl_remove 
> > + * libxl_device_usbctrl_destroy 
> > + */ 
> > + 
> > +#define DEFINE_DEVICE_REMOVE_EXT(type, removedestroy, f)\ 
>  
> As George has said, I would prefer to avoid committing this 
> duplication in-tree, even with a promise to de-duplicated it later. 
>  
>  
> > +void libxl__device_usbctrl_add(libxl__egc *egc, uint32_t domid, 
> > +   libxl_device_usbctrl *usbctrl, 
> > +   libxl__ao_device *aodev) 
> > +{ 
>  
> Thanks for adjusting the error-handling patterns in these functions. 
> The new way is good, except that: 
>  
> > +out: 
> > +aodev->rc = rc; 
> > +if (rc) aodev->callback(egc, aodev); 
>  
> Here, rc is always set, and indeed the code would be wrong if it were 
> not.  So can you remove the conditional please ?  Ie: 

Reading the codes, libxl__wait_device_connection will call aodev->callback
properly. So here, only if (rc != 0), that means error happens, then we need to
call aodev->callback to end the process. (Refer to current 
libxl__device_disk_add,
all current code does similar work.) So I think the code is not wrong (?)

>  
>   +   aodev->callback(egc, aodev); 
>  
> The same goes for: 
>  
> > +static int 
> > +libxl__device_usb_remove(libxl__gc *gc, uint32_t domid, libxl_device_usb  
> *usb); 
> ... 
>  
> > +/* Remove usb devices first */ 
> > +rc  = libxl__device_usb_list_for_usbctrl(gc, domid, usbctrl_devid, 
> > + , ); 
>  ^^ 
> While you're fixing other things, you could remove one of these space.s 
>  
> > +libxl_device_usbctrl * 
> > +libxl_device_usbctrl_list(libxl_ctx *ctx, uint32_t domid, int *num) 
> > +{ 
> ... 
> > +for (usbctrl = usbctrls; usbctrl < end; 
> > + usbctrl++, entry++, (*num)++) { 
>  
> I think this would be clearer if there were a line break at the first 
> semicolon too.  Ie, I like 
> for (A; B; C) { 
> or 
> for (A; 
>  B; 
>  C) { 
>  
> But I don't like very much 
> for (A; B; 
>  C) { 
> or 
> for (A; 
>  B; C) { 
>  
> > +#define READ_SUBPATH(path, subpath) ({  \ 
> > +rc = libxl__xs_read_checked(gc, XBT_NULL,   \ 
> > +GCSPRINTF("%s/" subpath, path), \ 
> > +);  \ 
> > +if (rc) goto outerr;\ 
> > +(char *)tmp;\ 
> > +}) 
>  
> Thanks, I'm pleased with how you have done this. 
>  
> > +be_path = READ_SUBPATH(fe_path, "backend"); 
> > +usbctrl->backend_domid = atoi(READ_SUBPATH(fe_path,  
> "backend-id")); 
> > +usbctrl->version = atoi(READ_SUBPATH(be_path, "usb-ver")); 
> > +usbctrl->ports = atoi(READ_SUBPATH(be_path, "num-ports")); 
>  
> However, I have a question: 
>  
> Why do you use atoi here, but strtoul in libxl_device_usbctrl_getinfo ? 

Didn't care much about that. atoi and strtoul both work. Previously use aoti,
in libxl_device_usbctrl_getinfo, to keep consistent with other functions (like
libxl_device_disk_getinfo), use strtoul.

Will update and use the same.

>  
> > +int libxl_device_usbctrl_getinfo(libxl_ctx *ctx, uint32_t domid, 
> > +libxl_device_usbctrl *usbctrl, 
> > +libxl_usbctrlinfo *usbctrlinfo) 
> > +{ 
> ... 
> > +tmp = READ_SUBPATH(fe_path, "backend-id"); 
> > +usbctrlinfo->backend_id = tmp ? strtoul(tmp, NULL, 10) : -1; 
>  
> There are ten copies of this pattern with tmp and strtoul.  I really 
> think this needs to be refactored somehow.  Can you 

Re: [Xen-devel] [PATCH v2 1/2] xen: move wallclock functions from x86 to common

2015-11-10 Thread Shannon Zhao
Hi Stefano,

When I apply this patch, there are some warnings.

Applying: xen: move wallclock functions from x86 to common
/home/open-source/xen/.git/rebase-apply/patch:268: trailing whitespace.
return wc_sec + (wc_nsec + NOW()) / 10ULL
/home/open-source/xen/.git/rebase-apply/patch:299: new blank line at EOF.
+
warning: 2 lines add whitespace errors.

On 2015/11/10 1:32, sstabell...@kernel.org wrote:
> From: Stefano Stabellini 
> 
> Remove dummy arm implementation of wallclock_time.
> Use shared_info() in common code rather than x86-ism to access it, when
> possible.
> 
> Define the static variable wc_sec, and the local variale sec in
> update_domain_wallclock_time, as uint64_t instead of unsigned long, to
> avoid size issue on arm.
> Take a uint64_t sec paramter in do_settime for the same reason.
> 
> Signed-off-by: Stefano Stabellini 
> CC: jbeul...@suse.com
> CC: andrew.coop...@citrix.com
> 
> ---
> Changes in v2:
> - remove stray blank lines
> - remove include 
> - move version_update_* to include/xen/time.h
> - introduce ifdef to fix build issue in common/time.c
> - define wc_sec and sec as uint64_t
> - pass u64 to do_settime
> ---
>  xen/arch/arm/time.c|5 ---
>  xen/arch/x86/time.c|   96 
> +---
>  xen/common/time.c  |   96 
> +++-
>  xen/include/xen/time.h |5 ++-
>  4 files changed, 100 insertions(+), 102 deletions(-)
> 
> diff --git a/xen/arch/arm/time.c b/xen/arch/arm/time.c
> index 5ded30c..6207615 100644
> --- a/xen/arch/arm/time.c
> +++ b/xen/arch/arm/time.c
> @@ -280,11 +280,6 @@ void domain_set_time_offset(struct domain *d, int64_t 
> time_offset_seconds)
>  /* XXX update guest visible wallclock time */
>  }
>  
> -struct tm wallclock_time(uint64_t *ns)
> -{
> -return (struct tm) { 0 };
> -}
> -
>  /*
>   * Local variables:
>   * mode: C
> diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c
> index bbb7e6c..0f16db5 100644
> --- a/xen/arch/x86/time.c
> +++ b/xen/arch/x86/time.c
> @@ -47,9 +47,6 @@ string_param("clocksource", opt_clocksource);
>  unsigned long __read_mostly cpu_khz;  /* CPU clock frequency in kHz. */
>  DEFINE_SPINLOCK(rtc_lock);
>  unsigned long pit0_ticks;
> -static unsigned long wc_sec; /* UTC time at last 'time update'. */
> -static unsigned int wc_nsec;
> -static DEFINE_SPINLOCK(wc_lock);
>  
>  struct cpu_time {
>  u64 local_tsc_stamp;
> @@ -783,10 +780,6 @@ uint64_t tsc_ticks2ns(uint64_t ticks)
>  return scale_delta(ticks, >tsc_scale);
>  }
>  
> -/* Explicitly OR with 1 just in case version number gets out of sync. */
> -#define version_update_begin(v) (((v)+1)|1)
> -#define version_update_end(v)   ((v)+1)
> -
>  static void __update_vcpu_system_time(struct vcpu *v, int force)
>  {
>  struct cpu_time   *t;
> @@ -900,37 +893,6 @@ void force_update_vcpu_system_time(struct vcpu *v)
>  __update_vcpu_system_time(v, 1);
>  }
>  
> -void update_domain_wallclock_time(struct domain *d)
> -{
> -uint32_t *wc_version;
> -unsigned long sec;
> -
> -spin_lock(_lock);
> -
> -wc_version = _info(d, wc_version);
> -*wc_version = version_update_begin(*wc_version);
> -wmb();
> -
> -sec = wc_sec + d->time_offset_seconds;
> -if ( likely(!has_32bit_shinfo(d)) )
> -{
> -d->shared_info->native.wc_sec= sec;
> -d->shared_info->native.wc_nsec   = wc_nsec;
> -d->shared_info->native.wc_sec_hi = sec >> 32;
> -}
> -else
> -{
> -d->shared_info->compat.wc_sec = sec;
> -d->shared_info->compat.wc_nsec= wc_nsec;
> -d->shared_info->compat.arch.wc_sec_hi = sec >> 32;
> -}
> -
> -wmb();
> -*wc_version = version_update_end(*wc_version);
> -
> -spin_unlock(_lock);
> -}
> -
>  static void update_domain_rtc(void)
>  {
>  struct domain *d;
> @@ -988,27 +950,6 @@ int cpu_frequency_change(u64 freq)
>  return 0;
>  }
>  
> -/* Set clock to  after 00:00:00 UTC, 1 January, 1970. */
> -void do_settime(unsigned long secs, unsigned int nsecs, u64 system_time_base)
> -{
> -u64 x;
> -u32 y;
> -struct domain *d;
> -
> -x = SECONDS(secs) + nsecs - system_time_base;
> -y = do_div(x, 10);
> -
> -spin_lock(_lock);
> -wc_sec  = x;
> -wc_nsec = y;
> -spin_unlock(_lock);
> -
> -rcu_read_lock(_read_lock);
> -for_each_domain ( d )
> -update_domain_wallclock_time(d);
> -rcu_read_unlock(_read_lock);
> -}
> -
>  /* Per-CPU communication between rendezvous IRQ and softirq handler. */
>  struct cpu_calibration {
>  u64 local_tsc_stamp;
> @@ -1608,25 +1549,6 @@ void send_timer_event(struct vcpu *v)
>  send_guest_vcpu_virq(v, VIRQ_TIMER);
>  }
>  
> -/* Return secs after 00:00:00 localtime, 1 January, 1970. */
> -unsigned long get_localtime(struct domain *d)
> -{
> -return wc_sec + (wc_nsec + NOW()) / 

Re: [Xen-devel] [PATCH v1 01/11] xsplice: Design document (v2).

2015-11-10 Thread Ross Lagerwall

On 11/03/2015 06:15 PM, Ross Lagerwall wrote:

From: Konrad Rzeszutek Wilk 

snip

+## Patching code
+
+The first mechanism to patch that comes in mind is in-place replacement.
+That is replace the affected code with new code. Unfortunately the x86
+ISA is variable size which places limits on how much space we have available
+to replace the instructions. That is not a problem if the change is smaller
+than the original opcode and we can fill it with nops. Problems will
+appear if the replacement code is longer.
+
+The second mechanism is by replacing the call or jump to the
+old function with the address of the new function.
+
+A third mechanism is to add a jump to the new function at the
+start of the old function.


Perhaps this document should be clarified to say what is actually 
implemented in this patch series? I.e. the third mechanism is the one 
that is actually implemented.



+
+### Example of trampoline and in-place splicing
+

snip

+## Addendum
+
+Implementation quirks should not be discussed in a design document.
+
+However these observations can provide aid when developing against this
+document.
+
+
+### Alternative assembler
+
+Alternative assembler is a mechanism to use different instructions depending
+on what the CPU supports. This is done by providing multiple streams of code
+that can be patched in - or if the CPU does not support it - padded with
+`nop` operations. The alternative assembler macros cause the compiler to
+expand the code to place a most generic code in place - emit a special
+ELF .section header to tag this location. During run-time the hypervisor
+can leave the areas alone or patch them with an better suited opcodes.


Note that if you patch any function that does a copy to or from guest 
memory, alternatives support is _required_ on Broadwell hardware because 
of SMAP (it patches in stac and clac).


This is actually implemented in this patch series.


+
+
+### When to patch
+
+During the discussion on the design two candidates bubbled where
+the call stack for each CPU would be deterministic. This would
+minimize the chance of the patch not being applied due to safety
+checks failing.
+
+ Rendezvous code instead of stop_machine for patching
+
+The hypervisor's time rendezvous code runs synchronously across all CPUs
+every second. Using the stop_machine to patch can stall the time rendezvous
+code and result in NMI. As such having the patching be done at the tail
+of rendezvous code should avoid this problem.
+
+However the entrance point for that code is
+do_softirq->timer_softirq_action->time_calibration
+which ends up calling on_selected_cpus on remote CPUs.
+
+The remote CPUs receive CALL_FUNCTION_VECTOR IPI and execute the
+desired function.
+
+ Before entering the guest code.
+
+Before we call VMXResume we check whether any soft IRQs need to be executed.
+This is a good spot because all Xen stacks are effectively empty at
+that point.
+
+To randezvous all the CPUs an barrier with an maximum timeout (which
+could be adjusted), combined with forcing all other CPUs through the
+hypervisor with IPIs, can be utilized to have all the CPUs be lockstep.
+
+The approach is similar in concept to stop_machine and the time rendezvous
+but is time-bound. However the local CPU stack is much shorter and
+a lot more deterministic.


This is implemented in this patch series.


+
+### Compiling the hypervisor code
+
+Hotpatch generation often requires support for compiling the target
+with -ffunction-sections / -fdata-sections.  Changes would have to
+be done to the linker scripts to support this.


As implemented, the current tool for payload generation requires no 
changes to Xen.
It is also possible to create a payload by compiling a C file containing 
the replacement functions that it completely separate from Xen itself.



+
+
+### Generation of xSplice ELF payloads
+
+The design of that is not discussed in this design.
+
+The author of this design envisions objdump and objcopy along
+with special GCC parameters (see above) to create .o.xsplice files
+which can be used to splice an ELF with the new payload.
+
+The ksplice or kpatching code can provide inspiration.


This is already implemented and the tool lives in a separate repo.


+
+### Exception tables and symbol tables growth
+
+We may need support for adapting or augmenting exception tables if
+patching such code.  Hotpatches may need to bring their own small
+exception tables (similar to how Linux modules support this).
+
+If supporting hotpatches that introduce additional exception-locations
+is not important, one could also change the exception table in-place
+and reorder it afterwards.


Almost every patch to a non-trivial function requires additional entries 
in the exception table and/or the bug frames.


This patch series allows each payload to introduce their own exception 
tables and bug frames to support this.



+
+### Security
+
+Only the privileged domain should be 

[Xen-devel] [ovmf test] 63933: all pass - PUSHED

2015-11-10 Thread osstest service owner
flight 63933 ovmf real [real]
http://logs.test-lab.xenproject.org/osstest/logs/63933/

Perfect :-)
All tests in this flight passed
version targeted for testing:
 ovmf 3ab1434a6ede4e006ef0b001108c354f4fa6d91e
baseline version:
 ovmf 3ec97ca490009ed5604ccd7f2653e5a9ecbf3474

Last test of basis63795  2015-11-08 01:58:30 Z2 days
Testing same since63933  2015-11-09 08:15:26 Z1 days1 attempts


People who touched revisions under test:
  Qiu Shumin 
  Yonghong Zhu 
  Zhang Lubo 

jobs:
 build-amd64-xsm  pass
 build-i386-xsm   pass
 build-amd64  pass
 build-i386   pass
 build-amd64-libvirt  pass
 build-i386-libvirt   pass
 build-amd64-pvopspass
 build-i386-pvops pass
 test-amd64-amd64-xl-qemuu-ovmf-amd64 pass
 test-amd64-i386-xl-qemuu-ovmf-amd64  pass



sg-report-flight on osstest.test-lab.xenproject.org
logs: /home/logs/logs
images: /home/logs/images

Logs, config files, etc. are available at
http://logs.test-lab.xenproject.org/osstest/logs

Explanation of these reports, and of osstest in general, is at
http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README.email;hb=master
http://xenbits.xen.org/gitweb/?p=osstest.git;a=blob;f=README;hb=master

Test harness code can be found at
http://xenbits.xen.org/gitweb?p=osstest.git;a=summary


Pushing revision :

+ branch=ovmf
+ revision=3ab1434a6ede4e006ef0b001108c354f4fa6d91e
+ . ./cri-lock-repos
++ . ./cri-common
+++ . ./cri-getconfig
+++ umask 002
+++ getrepos
 getconfig Repos
 perl -e '
use Osstest;
readglobalconfig();
print $c{"Repos"} or die $!;
'
+++ local repos=/home/osstest/repos
+++ '[' -z /home/osstest/repos ']'
+++ '[' '!' -d /home/osstest/repos ']'
+++ echo /home/osstest/repos
++ repos=/home/osstest/repos
++ repos_lock=/home/osstest/repos/lock
++ '[' x '!=' x/home/osstest/repos/lock ']'
++ OSSTEST_REPOS_LOCK_LOCKED=/home/osstest/repos/lock
++ exec with-lock-ex -w /home/osstest/repos/lock ./ap-push ovmf 
3ab1434a6ede4e006ef0b001108c354f4fa6d91e
+ branch=ovmf
+ revision=3ab1434a6ede4e006ef0b001108c354f4fa6d91e
+ . ./cri-lock-repos
++ . ./cri-common
+++ . ./cri-getconfig
+++ umask 002
+++ getrepos
 getconfig Repos
 perl -e '
use Osstest;
readglobalconfig();
print $c{"Repos"} or die $!;
'
+++ local repos=/home/osstest/repos
+++ '[' -z /home/osstest/repos ']'
+++ '[' '!' -d /home/osstest/repos ']'
+++ echo /home/osstest/repos
++ repos=/home/osstest/repos
++ repos_lock=/home/osstest/repos/lock
++ '[' x/home/osstest/repos/lock '!=' x/home/osstest/repos/lock ']'
+ . ./cri-common
++ . ./cri-getconfig
++ umask 002
+ select_xenbranch
+ case "$branch" in
+ tree=ovmf
+ xenbranch=xen-unstable
+ '[' xovmf = xlinux ']'
+ linuxbranch=
+ '[' x = x ']'
+ qemuubranch=qemu-upstream-unstable
+ select_prevxenbranch
++ ./cri-getprevxenbranch xen-unstable
+ prevxenbranch=xen-4.6-testing
+ '[' x3ab1434a6ede4e006ef0b001108c354f4fa6d91e = x ']'
+ : tested/2.6.39.x
+ . ./ap-common
++ : osst...@xenbits.xen.org
+++ getconfig OsstestUpstream
+++ perl -e '
use Osstest;
readglobalconfig();
print $c{"OsstestUpstream"} or die $!;
'
++ :
++ : git://xenbits.xen.org/xen.git
++ : osst...@xenbits.xen.org:/home/xen/git/xen.git
++ : git://xenbits.xen.org/qemu-xen-traditional.git
++ : git://git.kernel.org
++ : git://git.kernel.org/pub/scm/linux/kernel/git
++ : git
++ : git://xenbits.xen.org/libvirt.git
++ : osst...@xenbits.xen.org:/home/xen/git/libvirt.git
++ : git://xenbits.xen.org/libvirt.git
++ : git://xenbits.xen.org/rumpuser-xen.git
++ : git
++ : git://xenbits.xen.org/rumpuser-xen.git
++ : osst...@xenbits.xen.org:/home/xen/git/rumpuser-xen.git
+++ besteffort_repo https://github.com/rumpkernel/rumpkernel-netbsd-src
+++ local repo=https://github.com/rumpkernel/rumpkernel-netbsd-src
+++ cached_repo https://github.com/rumpkernel/rumpkernel-netbsd-src 
'[fetch=try]'
+++ local repo=https://github.com/rumpkernel/rumpkernel-netbsd-src
+++ local 'options=[fetch=try]'
 getconfig GitCacheProxy
 perl -e '
use Osstest;
readglobalconfig();
print $c{"GitCacheProxy"} or die $!;
'
+++ local cache=git://cache:9419/
+++ '[' xgit://cache:9419/ '!=' x ']'
+++ echo 

Re: [Xen-devel] [PATCH v2 1/2] xen: move wallclock functions from x86 to common

2015-11-10 Thread Jan Beulich
>>> On 09.11.15 at 18:32,  wrote:
> From: Stefano Stabellini 
> 
> Remove dummy arm implementation of wallclock_time.
> Use shared_info() in common code rather than x86-ism to access it, when
> possible.
> 
> Define the static variable wc_sec, and the local variale sec in
> update_domain_wallclock_time, as uint64_t instead of unsigned long, to
> avoid size issue on arm.
> Take a uint64_t sec paramter in do_settime for the same reason.
> 
> Signed-off-by: Stefano Stabellini 
> CC: jbeul...@suse.com 
> CC: andrew.coop...@citrix.com 
> 
> ---
> Changes in v2:
> - remove stray blank lines

There's still one left at the end of xen/common/time.c, but anyway
Acked-by: Jan Beulich 


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v9 00/17] Add VT-d Posted-Interrupts support

2015-11-10 Thread Jan Beulich
>>> On 10.11.15 at 08:33,  wrote:
> Thanks for your effort on this series and kindly ping..

Don't worry, it hasn't been forgotten. But getting to it will take time.

Jan


___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


Re: [Xen-devel] [PATCH v2 2/2] arm: export platform_op XENPF_settime64

2015-11-10 Thread Shannon Zhao
Hi Stefano,

When I apply this patch, there are some warnings too.

Applying: arm: export platform_op XENPF_settime64
/home/open-source/xen/.git/rebase-apply/patch:67: trailing whitespace.
 *
/home/open-source/xen/.git/rebase-apply/patch:69: trailing whitespace.
 *
/home/open-source/xen/.git/rebase-apply/patch:172: trailing whitespace.

warning: 3 lines add whitespace errors.

On 2015/11/10 1:32, sstabell...@kernel.org wrote:
> From: Stefano Stabellini 
> 
> Call update_domain_wallclock_time at domain initialization, specifically
> in arch_set_info_guest for vcpu0, like we do on x86.
> Set time_offset_seconds to the number of seconds between phisical boot
> and domain initialization: it is going to be used to get/set the
> wallclock time.
> Add time_offset_seconds to system_time when before calling do_settime,
> so that system_time actually accounts for all the time in nsec between
> machine boot and when the wallclock was set.
> 
> 
> 
> Signed-off-by: Stefano Stabellini 
> CC: dgde...@tycho.nsa.gov
> 
> ---
> 
> Changes in v2:
> - drop XENPF_settime32
> - set time_offset_seconds
> - modify xen/xsm/flask/hooks.c
> ---
>  xen/arch/arm/Makefile |1 +
>  xen/arch/arm/domain.c |9 ++
>  xen/arch/arm/platform_hypercall.c |   62 
> +
>  xen/arch/arm/traps.c  |1 +
>  xen/arch/arm/vtimer.c |1 -
>  xen/include/asm-arm/time.h|2 ++
>  xen/include/xsm/dummy.h   |   12 +++
>  xen/include/xsm/xsm.h |   13 
>  xen/xsm/flask/hooks.c |2 +-
>  9 files changed, 89 insertions(+), 14 deletions(-)
>  create mode 100644 xen/arch/arm/platform_hypercall.c
> 
> diff --git a/xen/arch/arm/Makefile b/xen/arch/arm/Makefile
> index 1ef39f7..240aa29 100644
> --- a/xen/arch/arm/Makefile
> +++ b/xen/arch/arm/Makefile
> @@ -23,6 +23,7 @@ obj-y += percpu.o
>  obj-y += guestcopy.o
>  obj-y += physdev.o
>  obj-y += platform.o
> +obj-y += platform_hypercall.o
>  obj-y += setup.o
>  obj-y += bootfdt.o
>  obj-y += time.o
> diff --git a/xen/arch/arm/domain.c b/xen/arch/arm/domain.c
> index b2bfc7d..1f07a41 100644
> --- a/xen/arch/arm/domain.c
> +++ b/xen/arch/arm/domain.c
> @@ -21,6 +21,7 @@
>  #include 
>  
>  #include 
> +#include 
>  #include 
>  #include 
>  #include 
> @@ -742,6 +743,14 @@ int arch_set_info_guest(
>  v->arch.ttbr1 = ctxt->ttbr1;
>  v->arch.ttbcr = ctxt->ttbcr;
>  
> +if ( v->vcpu_id == 0 )
> +{
> +struct domain *d = v->domain;
> +d->time_offset_seconds = ticks_to_ns(d->arch.virt_timer_base.offset 
> - boot_count);
> +do_div(d->time_offset_seconds, 10);
> +update_domain_wallclock_time(d);
> +}
> +
>  v->is_initialised = 1;
>  
>  if ( ctxt->flags & VGCF_online )
> diff --git a/xen/arch/arm/platform_hypercall.c 
> b/xen/arch/arm/platform_hypercall.c
> new file mode 100644
> index 000..cb8e575
> --- /dev/null
> +++ b/xen/arch/arm/platform_hypercall.c
> @@ -0,0 +1,62 @@
> +/**
> + * platform_hypercall.c
> + * 
> + * Hardware platform operations. Intended for use by domain-0 kernel.
> + * 
> + * Copyright (c) 2015, Citrix
> + */
> +
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +#include 
> +
> +DEFINE_SPINLOCK(xenpf_lock);
> +
> +long do_platform_op(XEN_GUEST_HANDLE_PARAM(xen_platform_op_t) u_xenpf_op)
> +{
> +long ret;
> +struct xen_platform_op curop, *op = 
> +struct domain *d;
> +
> +if ( copy_from_guest(op, u_xenpf_op, 1) )
> +return -EFAULT;
> +
> +if ( op->interface_version != XENPF_INTERFACE_VERSION )
> +return -EACCES;
> +
> +d = rcu_lock_current_domain();
> +if ( d == NULL )
> +return -ESRCH;
> +
> +ret = xsm_platform_op(XSM_PRIV, op->cmd);
> +if ( ret )
> +return ret;
> +
> +spin_lock(_lock);
> +
> +switch ( op->cmd )
> +{
> +case XENPF_settime64:
> +if ( likely(!op->u.settime64.mbz) )
> +do_settime(op->u.settime64.secs,
> +   op->u.settime64.nsecs,
> +   op->u.settime64.system_time + 
> SECONDS(d->time_offset_seconds));
> +else
> +ret = -EINVAL;
> +break;
> +
> +default:
> +ret = -ENOSYS;
> +break;
> +}
> +
> +spin_unlock(_lock);
> +rcu_unlock_domain(d);
> +return ret;
> +}
> diff --git a/xen/arch/arm/traps.c b/xen/arch/arm/traps.c
> index 9d2bd6a..c49bd3f 100644
> --- a/xen/arch/arm/traps.c
> +++ b/xen/arch/arm/traps.c
> @@ -1233,6 +1233,7 @@ static arm_hypercall_t arm_hypercall_table[] = {
>  HYPERCALL(hvm_op, 2),
>  HYPERCALL(grant_table_op, 3),
>  HYPERCALL(multicall, 2),
> +HYPERCALL(platform_op, 1),
>  HYPERCALL_ARM(vcpu_op, 3),
>  };
>  
> diff --git 

[Xen-devel] [ovmf baseline-only test] 38264: all pass

2015-11-10 Thread Platform Team regression test user
This run is configured for baseline tests only.

flight 38264 ovmf real [real]
http://osstest.xs.citrite.net/~osstest/testlogs/logs/38264/

Perfect :-)
All tests in this flight passed
version targeted for testing:
 ovmf 3ab1434a6ede4e006ef0b001108c354f4fa6d91e
baseline version:
 ovmf 3ec97ca490009ed5604ccd7f2653e5a9ecbf3474

Last test of basis38261  2015-11-09 06:21:06 Z1 days
Testing same since38264  2015-11-10 10:21:29 Z0 days1 attempts


People who touched revisions under test:
  Qiu Shumin 
  Yonghong Zhu 
  Zhang Lubo 

jobs:
 build-amd64-xsm  pass
 build-i386-xsm   pass
 build-amd64  pass
 build-i386   pass
 build-amd64-libvirt  pass
 build-i386-libvirt   pass
 build-amd64-pvopspass
 build-i386-pvops pass
 test-amd64-amd64-xl-qemuu-ovmf-amd64 pass
 test-amd64-i386-xl-qemuu-ovmf-amd64  pass



sg-report-flight on osstest.xs.citrite.net
logs: /home/osstest/logs
images: /home/osstest/images

Logs, config files, etc. are available at
http://osstest.xs.citrite.net/~osstest/testlogs/logs

Test harness code can be found at
http://xenbits.xensource.com/gitweb?p=osstest.git;a=summary


Push not applicable.


commit 3ab1434a6ede4e006ef0b001108c354f4fa6d91e
Author: Yonghong Zhu 
Date:   Mon Nov 9 07:43:07 2015 +

BaseTools: Allow decimal values in the EDK II meta-data file

Because the EDK II meta-data specifications already allow using decimal
values in the EDK II Meta-data file [Defines] section, this patch update
code to allow this usage.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Yonghong Zhu 
Reviewed-by: Liming Gao 

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18746 
6f19259b-4bc3-4df7-8a09-765794883524

commit ac4588532d17a2f3cac3e7dde7c85ed59dab319b
Author: Zhang Lubo 
Date:   Mon Nov 9 07:00:20 2015 +

NetworkPkg:Fix the issue that cannot parse ipv6 address correctly.

If there is a ipv6 expressed url, the NetLibAsciiStrToIp6 cannot get the 
Ipv6
address from the host name, because the host name contains left and right
bracket which cannot be used to configure the Tcp6 connection.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Reviewed-by: Ye Ting 
Reviewed-by: Fu Siyuan 
Reviewed-by: Wu Jiaxin 

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18745 
6f19259b-4bc3-4df7-8a09-765794883524

commit e91cc29dd71c9597dbf835b068e4d4d9b1ccb97d
Author: Zhang Lubo 
Date:   Mon Nov 9 03:45:23 2015 +

MdeModulePkg:Fix a bug that HttpLib can not parse Ipv6 address correctly.

When parsing the authority component of the input URL, it can not 
distinguish
the ":" is the flag that indicates the port or the separator between
the ipv6 address.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Reviewed-by: Fu Siyuan 
Reviewed-by: Wu Jiaxin 
Reviewed-by: Gary Ching-Pang Lin 

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18744 
6f19259b-4bc3-4df7-8a09-765794883524

commit b659408b933f40765960e877de3e1f8ceaab52cb
Author: Zhang Lubo 
Date:   Mon Nov 9 03:30:42 2015 +

NetworkPkg:Enable Http Boot over Ipv6 stack

Add new features to support Http boot over ipv6 stack.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Zhang Lubo 
Reviewed-by: Fu Siyuan 
Reviewed-by: Ye Ting 
Reviewed-by: Wu Jiaxin 

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18743 
6f19259b-4bc3-4df7-8a09-765794883524

commit d1c275c651099c7f187885412b7751327b86ca38
Author: Qiu Shumin 
Date:   Mon Nov 9 02:29:31 2015 +

ShellPkg: Don't strip positional parameters of quotation marks.

Per Shell SPEC 2.1 'Double-quotation marks that 

Re: [Xen-devel] [PATCH v2 1/7] timekeeping: introduce __current_kernel_time64

2015-11-10 Thread Peter Zijlstra
On Tue, Nov 10, 2015 at 11:57:49AM +, Stefano Stabellini wrote:
> __current_kernel_time64 returns a struct timespec64, without taking the
> xtime lock. Mirrors __current_kernel_time/current_kernel_time.

It always helps if you include a reason why you want a patch.

___
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel


  1   2   >